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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(void){
    int64_t n; cin >> n;
    string s; cin >> s;
    
    int64_t r_cnt = 0;
    int64_t g_cnt = 0;
    int64_t b_cnt = 0;
    
    for(int i = 0; i < n; i++){
        if(s.at(i) == 'R') r_cnt++;
        if(s.at(i) == 'G') g_cnt++;
        if(s.at(i) == 'B') b_cnt++;
    }
    
    int64_t total = r_cnt * g_cnt * b_cnt;
    
    
    for(int i = 0; i < n-2; i++){
        for(int j = i + 1; j < n-1; j++){
            int k = 2 * j - i;
            if(k >= n){
                break;
            }
            if((s.at(i) != s.at(j)) && (s.at(i) != s.at(k)) && (s.at(j) != s.at(k))){
                total--;
            }
        }
    }
    
    cout << total << endl;
    
    
}


Measured memory_bytes: 3620
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int r, s, p;
int win(char c) {
	switch(c) {
		case 'r':
			return p;
		case 's':
			return r;
		case 'p':
			return s;
	}
}

int main() {
	int n, k;

	scanf("%d %d", &n, &k);
	scanf("%d %d %d", &r, &s, &p);
	char t[n + 1];
	scanf("%s", t);
	vector<vector<char>> rsp(k);
	REP(i, n) { rsp[i % k].push_back(t[i]); }

	int result = 0;
	REP(i, k) {
		int size = rsp[i].size();
		VI dp(size, 0);
		REP(j, size) {
			if(j == 0 || rsp[i][j] != rsp[i][j - 1]) {
				dp[j] += (j == 0 ? 0 : dp[j - 1]) + win(rsp[i][j]);
			} else {
				dp[j] = dp[j - 1];
				rsp[i][j] = '-';
			}
		}
		result += dp[size - 1];
	}
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 5120
#include<cstdio>

int main()
{
    int i=0,j=0,a[10]={0},temp;
    for(i=0;i<=9;i++) scanf("%d",&a[i]);
    for(i=j;i<=9;i++)
    {
       for(j=0;j<=2;j++)
            if(a[i]>a[j])
            {
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
    }
    printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
    return 0;

}

Measured memory_bytes: 1032
A, B, C, X = int(input()), int(input()), int(input()), int(input())
ans = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

#define MAX 100

int main(void)
{
    int i, j, k;

    int in_mat1_row, in_mat1_col, in_mat2_row, in_mat2_col;
    scanf("%d %d %d", &in_mat1_row, &in_mat1_col, &in_mat2_col);
    in_mat2_row = in_mat1_col;

    int in_mat1[MAX][MAX];
    for (i = 0; i < in_mat1_row; i++) {
        for (j = 0; j < in_mat1_col; j++) {
            scanf("%d", &in_mat1[i][j]);
        }
    }

    int in_mat2[MAX][MAX];
    for (i = 0; i < in_mat2_row; i++) {
        for (j = 0; j < in_mat2_col; j++) {
            scanf("%d", &in_mat2[i][j]);
        }
    }

    long out_mat[MAX][MAX];
    for (i = 0; i < in_mat1_row; i++) {
        for (j = 0; j < in_mat2_col; j++) {
            out_mat[i][j] = 0;
            for (k = 0; k < in_mat1_col; k++) {
                out_mat[i][j] += in_mat1[i][k] * in_mat2[k][j];
            }
            if (j != 0) {
                printf(" ");
            }
            printf("%ld", out_mat[i][j]);
        }
        printf("\n");
    }

    return 0;
}

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

int main () {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  bool boolean = true;
  for (int i = k; i < n; i++) {
    if (a.at(i) <= a.at(i-k)) {
      boolean = false;
      cout << "No" << endl;
    } else cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 3552
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin  = open("input.txt","r")
    sys.stdout = open("output.txt","w")
    sys.stderr = open("output.txt","w")

# for _testcases_ in range(int(input())):
s= input()
li = []
for i in s:
    if i == 'B':
        try: li.pop()
        except: pass
    else:
        li.append(i)
print("".join(li))

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
using namespace std;
const int MOD=1e9+7;

void add( long long &v, long long x ) {
    (v+=x)%=MOD;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n,k;
    cin >> n >> k;
    vector<int> A(n),B;
    REP(i,n) cin >> A[i];
    B=A;
    sort(B.begin(), B.end());
    long long t=0, ans=0;
    // single array inversion
    for ( int i=0; i<n; i++ ) {
        for ( int j=i+1; j<n; j++ ) {
            if ( A[i]>A[j] ) t++;
        }
    }
    add(ans, t*k%MOD);
    // count inversion of append
    t=0;
    for ( int i=0; i<n; i++ ) {
        int x = lower_bound(B.begin(), B.end(), A[i]) - B.begin();
        t+=x;
    }
    add(ans, (long long)k*(k-1)/2%MOD*t%MOD);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
    int i=0;
    int n;
    int a;
    int x=0,y=0,z=0;
    //scanf("%d",&n);
    for(;~scanf("%d",&a);){
        i++?a%2?z--:(a%4?y++:z++):0;
        /*
        if(a%2){
            z--;
        }else if(a%4){
            y++;
        }else{
            z++;
        }*/
    }
    //printf("%d %d\n",y,z);
    puts((!y&&z>-2||y&&z+1)?"Yes":"No");
}

Measured memory_bytes: 1644
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		if (x >= a && x <= a + b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
using namespace std;
typedef long long ll;

int main() {
	int n,m;
	cin >> n >> m;
	int t = 100*(n-m) + 1900*m;
	double p = 1;
	rep(i,m){
		p /= 2;
	}
	double ans = 0;
	rep(i,1e3){
		double q = 1;
		rep(j,i){
			q *= 1-p;
		}
		ans += t*(i+1) * p * q;
	}
	cout << round(ans) << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
dp = [[ 0] * (len(S) + 1 ) for _ in range(len(T) + 1)]
ma = 0
for i in range(len(dp)-1):
    for j in range(len(dp[0])-1):
        if T[i ] == S[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
             dp[i + 1][j + 1]  = max(dp[i][j + 1],dp[i +1][j])
i = len(T) - 1
j = len(S) - 1 
ans = ""
while i >=0 and j >= 0:
    if dp[i][j+1] == dp[i + 1][j + 1]:
        i-=1
    elif dp[i + 1][j] == dp[i + 1][j + 1]:
        j-=1
    else:
        #print(j,i)
        ans = S[j] + ans
        i-=1
        j-=1
print(ans)

Measured memory_bytes: 112732
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,x;
  cin >> N >> x;
  vector<int> a(N);
  int ans = 0;
  for(int i = 0; i < N; i++) cin >> a[i];
  
  sort(a.begin(),a.end());
  
  for(int i = 0; i < N; i++){
    if(x >= a[i]){
      x -= a[i];
      ans++;
    } else {
      x -= a[i];
      break;
    }
  }
  
  if( x > 0){
    ans--;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    int h,w;
    while(cin>>h>>w){
        if(h==0&&w==0) break;
        else{
            REP(i,h){
                REP(j,w){
                    if(i==0||i==h-1){
                        cout << '#';
                    }
                    else{
                        if(j==0||j==w-1){
                            cout <<'#';
                        }
                        else{
                            cout << '.';
                        }
                    }
                }
                cout << endl;
            }
            cout << endl;
        }
    }
}


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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  
  ll sum = 0;

  rep (i, n) sum += a[i];

  sort(a.begin(), a.end(), greater<ll>());

  ll count = 0;

  rep(i, m) {
    if ((4 * m * a[i]) >= sum) {
      count++;
    }
  }

  if (count == m) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 1024

void push(int a, int arr[]);
int pop (int arr[]);

int main() {
	int num;
	int arr[MAX] = {0};

	while(scanf("%d", &num) != EOF) {
		if(num == 0) {
			printf("%d\n", pop(arr));
		} else {
			push(num, arr);
		}
	}

	return 0;
}

void push(int a, int arr[]) {
	//be careful of the vanish of the last element.
	int i;
	for(i = MAX - 1; i > 0; i--) {
		arr[i] = arr[i-1];
	}
	arr[0] = a;
}

int pop(int arr[]) {
	int r = arr[0];
	int i;
	for(i = 0; i < MAX - 1; i++) {
		arr[i] = arr[i + 1];
	}
	arr[MAX-1] = 0;

	return r;
}

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

using namespace std;

typedef long long ll;
const int INF = 1000000000;

int main()
{
  int n, m, x;
  scanf("%d %d %d", &n, &m, &x);
  vector<int> boxes(n + 1, 0);
  for (int i = 0; i < m; ++i) {
    int pos;
    scanf("%d", &pos);
    boxes[pos] = 1;
  }
  int ans = INF;
  // rightward
  int total = 0;
  for (int i = x + 1; i <= n; ++i) {
    total += boxes[i];
  }
  ans = min(ans, total);
  total = 0;
  // leftward
  for (int i = x - 1; i >= 0; --i) {
    total += boxes[i];
  }
  ans = min(ans, total);
  printf("%d\n", ans);

  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1L<<61);

int main() {
  int m1, d1; cin >> m1 >> d1;
  int m2, d2; cin >> m2 >> d2;
  cout << (d2==1) << endl;
  return 0;
}


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

"""
・自力AC
・数え上げDP
・計算量O(H*W)=1000*1000=100万、pythonで1.4秒、pypyで0.8秒くらい。
・貰うDPを配るDPにしてみた。
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()

# 四方に一回り大きいグリッドを作る
grid = [['#'] * (W+2) for i in range(H+2)]
for i in range(1,H+1):
    row = list(input())
    for j in range(1, W+1):
        grid[i][j] = row[j-1]

dp = [[0] * (W+2) for i in range(H+2)]
# スタート地点に1通りを初期値設定
dp[1][1] = 1
for i in range(1,H+1):
    for j in range(1, W+1):
        # 現在位置が壁なら何もできない
        if grid[i][j] == '#':
            continue
        # 下が壁でなければ、値を送る
        if grid[i+1][j] != '#':
             dp[i+1][j] += dp[i][j]
        # 右が壁でなければ、値を送る
        if grid[i][j+1] != '#':
            dp[i][j+1] += dp[i][j]
# ゴール地点の値を確認する
print(dp[H][W] % MOD)


Measured memory_bytes: 255416
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, m;
  m = 0;
  cin >> a;
  vector<int> vec(a);
  vector<int> vec2(a);
  vector<int> vec3(a);
  vector<int> vec4(a);
  for (int i = 0; i < a; i++) {
    cin >> vec.at(i);
    vec3.at(i) = vec.at(i);
  }
  for (int i = 0; i < a; i++) {
    if (vec.at(i) > m) {
      m = vec.at(i);
    }
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < a; i++) {
    vec2.at(i) = vec.at(i);
    vec4.at(i) = vec.at(i);
  }
  while (vec2.back() == m && vec2.size() > 1) {
    vec2.pop_back();
  }
  vec4.pop_back();
  for (int i = 0; i < a; i++) {
    if (vec3.at(i) == m) {
      cout << vec4.back() << endl;
    }
    else {
      cout << m << endl;
    }
  }
}

Measured memory_bytes: 4736
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#define mod 998244353
#define int long long int
int function(int arr[],int initial,int final,int memo[][10],int status)
{
	if(initial>final)
	{
		if(status==0)
		    return -mod;
		else
		   return 0;
	}
	if(memo[initial][status]!=-1)
	    return memo[initial][status];
	else
	{
		int x=arr[initial]+function(arr,initial+1,final,memo,(status+arr[initial])%10);
		int y=function(arr,initial+1,final,memo,status);
		memo[initial][status]=max(x,y);
		return memo[initial][status];
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
    cin>>n;
    int arr[n],j;
    for(j=0;j<n;j++)
       cin>>arr[j];
    int memo[n+1][10];
    int i;
    for(i=0;i<=n;i++)
    {
		for(j=0;j<10;j++)
		{
			memo[i][j]=-1;
		}
	}
	int answer=function(arr,0,n-1,memo,0);
	if(answer<0)
	   cout<<0<<endl;
	else
	   cout<<answer<<endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
list = gets.chomp.split(' ').map(&:to_i)

def selection_sort(list)
  cnt = 0
  (0..(list.length - 1)).each do |i|
    minj = i
    (i..(list.length - 1)).each do |j|
      if list[j] < list[minj]
        minj = j
      end
    end
    cnt += 1 if i != minj
    v1 = list[i]
    v2 = list[minj]
    list[i] = v2
    list[minj] = v1
  end

  return list, cnt
end

list, cnt = selection_sort(list)
puts list.join(' ')
puts cnt



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

using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
int a[MAXN];
set<int> s;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    a[0] = 0;
    a[n + 1] = 0;
    ll ans = 0;
    bool cao = true;
    for (int i = 1; i <= n + 1; i++) {
        if (cao) {
            if (a[i] >= a[i - 1])
                ans += a[i] - a[i - 1];
            else {
                ans += a[i - 1] - a[i];
                cao = false;
            }
        } else {
            if (a[i] <= a[i - 1])
                ans += a[i - 1] - a[i];
            else {
                ans += a[i] - a[i - 1];
                cao = true;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        if ((a[i] >= a[i - 1] && a[i + 1] >= a[i]) || (a[i] <= a[i - 1] && a[i + 1] <= a[i]))
            cout << ans << endl;
        else {
            if (a[i] >= a[i - 1] && a[i + 1] <= a[i])
                cout << ans - (abs(a[i] - max(a[i - 1], a[i + 1]))) * 2 << endl;
            else if (a[i] <= a[i - 1] && a[i + 1] >= a[i] - 1)
                cout << ans - (abs(min(a[i + 1], a[i - 1]) - a[i])) * 2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    bool flag = false;
    for(int i=0;i<s.size()-1;++i){
        if(s[i] == 'A' && s[i+1] == 'C')flag = true;
    }
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
 
    return 0;
}

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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int S = in.nextInt();

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < K; i++) {
                sb.append(S).append(' ');
            }
            int a = S == 1e9 ? 1 : S + 1;
            for (int i = K; i < N; i++) {
                sb.append(a).append(' ');
            }
            out.println(sb.substring(0, sb.length() - 1));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 29648
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 100001
using namespace std;
typedef long long ll;

int main(){
  int N;  cin >> N;
  vector<float> vec(N);
  float sum = 0;
  float minF = 100100;
  int ansP = 0;
  float avg;
  rep(i, 0, N){
    cin >> vec[i];
    sum+=vec[i];
  }
  avg = sum / N;
  rep(i, 0, N){
    vec[i] = abs(vec[i]-avg);
    if(minF > vec[i]){
      minF = vec[i];
      ansP = i;
    }
  }
  cout << ansP << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    if( N < 105) cout <<0 << "\n";
    else if(N< 135) cout << 1 << "\n";
    else if(N < 165) cout << 2 << "\n";
    else if(N < 189) cout << 3 << "\n";
    else if(N < 195) cout << 4 << "\n";
    else cout << 5 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  string s, t;
  cin >> s >> t;
  int a = s.size();
  int b = t.size();
  int ans = b;
  rep(i,a-b+1) {
    int tmp = 0;
    rep(j,b) if(s[i+j]!=t[j]) tmp++;
    ans = min(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i*i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  return res;
}

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

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

  vector<ll> sum(1000010);
  for (ll i = 0; i < n; ++i) {
    bool ok = true;;
    for (ll j = 1; j*j <= a[i]; ++j) {
      if (a[i]%j == 0) {
        if (sum[j] > 0) ok = false;
        if (j != a[i]/j) {
          if (sum[a[i]/j] > 0) ok = false;
        }
      }
      if (!ok) break;
    }
    if (ok || sum[a[i]] > 0) {
      sum[a[i]]++;
    }
  }

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    if (sum[a[i]] == 1) ++ans;
  }

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


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

using namespace std;

typedef long long int	lli;

const int N = 20;
int dp[N][2], used[N][2];
int v[N];
lli d = 0LL;

int solve(int i, int b){
	if(i == d){
		return 0;
	}
	
	int &ans = dp[i][b];
	
	if(used[i][b]){
		return ans;
	}
	
	used[i][b] = 1;
	
	if(b){
		ans = solve(i + 1, b) + 9;
	}else{
		for(int k = v[i] ; k >= 0 ; k--){
			ans = max(ans, solve(i + 1, k < v[i]) + k);
		}
	}
	
	return ans;
}

int main (){
	lli n;
	
	cin >> n;
	
	lli num = 0LL;
	lli pot = 10LL;
	lli tmp = n;
		
	while(tmp){
		v[d] = tmp % 10;
		tmp /= 10LL;
		d++;
	}
	
	reverse(v, v + d);
	
	cout << solve(0, 0) << '\n';
	
	return 0;
}

Measured memory_bytes: 256
import sys

for s in list(sys.stdin):
    a,b,e,c,d,f = map(float,s.split())
    base = a*d-b*c
    x = e*d-b*f
    y = a*f-e*c
    print('%.3f %.3f' % (x/base+0,y/base+0))

Measured memory_bytes: 7344
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    int x = Integer.parseInt(str[3]);
    int y = Integer.parseInt(str[4]);
    int sum = 0;
    int ans = a*x+b*y;
    
    for(int i=0; i<=2*Math.max(x,y)+2; i+=2){
      sum = Math.max(0,(x-i/2))*a+Math.max(0,(y-i/2))*b+i*c;
      ans = Math.min(ans,sum);
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 32752
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * fh;
}

typedef long long ll;
const ll inf = 1e9;
bool flag = false;
ll rel = inf, ans = 0;

int main () {
	For (i, 1, read()) {
		ll x = read(), y = read(); ans += x;
		if (x > y) rel = min(rel, y);
		if (x ^ y) flag = true;
	}
	ans -= rel;
	printf ("%lld\n", flag ? ans : 0);
    return 0;
}


Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,M = II()

if N==1:
    if M==1:
        print(1)
    else:
        print(M-2)
else:
    if M==1:
        print(N-2)
    else:
        print((M-2)*(N-2))

Measured memory_bytes: 38384
#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define INF 100000000
int heap[MAX+1],Haruhi;

void maxHeapify(int i){
  int temp;
  int l,r,largest;
  l = 2*i;
  r = 2*i+1;

  if(l<=Haruhi && heap[l] > heap[i]) largest = l;
  else largest = i;
  if(r<=Haruhi && heap[r]>heap[largest]) largest = r;
  if(largest != i){
    temp = heap[i];
    heap[i] = heap[largest];
    heap[largest] = temp;
    maxHeapify(largest);
  }
}

void increaseKey(int i,int key){
  int temp;

  heap[i] = key;
  while(i>1 && heap[i/2]<heap[i]){
    temp = heap[i];
    heap[i] = heap[i/2];
    heap[i/2] = temp;
    i /= 2;
  }
}


void insert(int key){
  Haruhi++;
  heap[Haruhi] = -INF;
  increaseKey(Haruhi,key);
}

void extract(){
  printf("%d\n",heap[1]);
  heap[1] = heap[Haruhi--];
  maxHeapify(1);
}

int main(){
  int kota;
  char s[10];

  while(1){
    scanf("%s",s);
    if(s[0]=='e' && s[1]=='n') break;
    if(s[0]=='i'){
      scanf("%d",&kota);
      insert(kota);
    }
    if(s[0]=='e') extract();
  }

  return 0;
}



Measured memory_bytes: 5676
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair

vector<vector<vector<ll>>> e(110000);


int main(){
    ll n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        ll u,v,s;
        cin>>u>>v>>s;
        e[u].push_back({v,s});
        e[v].push_back({u,s});
    }
    
    bool nibu=true;
    bool able=true;
    
    queue<ll> q;
    int color[110000]={};
    ll a[110000];
    fill(a,&a[110000],E);
    q.push(1);
    color[1]=1;
    a[1]=0;
    
    while(!q.empty()){
        ll s=q.front();
        q.pop();
        //cout<<"s "<<s<<endl;
        for(int i=0;i<e[s].size();i++){
            vector<ll> l=e[s][i];
            if(color[l[0]]==color[s]){
                nibu=false;
                if((l[1]-a[s]-a[l[0]])%2!=0){able=false; break;}
                ll k=(l[1]-a[s]-a[l[0]])/2;
                for(int t=1;t<=n;t++){
                    if(color[t]==color[s]){a[t]+=k;}
                    if(color[t]==-1*color[s]){a[t]-=k;}
                }
                nibu=false;
                break;
            }
            if(color[l[0]]==0){q.push(l[0]);}
            color[l[0]]=-1*color[s];
            if(a[l[0]]!=E && a[l[0]]!=l[1]-a[s]){able=false; break;}
            a[l[0]]=l[1]-a[s];
        }
        if(!nibu){break;}
    }
    
    if(!able){cout<<0<<endl;}
    else if(nibu){
        ll mi1=E,mi2=E;
        for(int i=1;i<=n;i++){
            if(color[i]==1){mi1=min(mi1,a[i]);}
            if(color[i]==-1){mi2=min(mi2,a[i]);}
        }
        mi1+=mi2;
        if(mi1-1<1){cout<<0<<endl;}
        else{cout<<mi1-1<<endl;}
    }
    else{
        bool done[110000]={};
        q.push(1);
        
        while(!q.empty()){
            ll s=q.front();
            q.pop();
            done[s]=true;
            for(int i=0;i<e[s].size();i++){
                vector<ll> l=e[s][i];
                if(a[l[0]]==E){a[l[0]]=l[1]-a[s]; q.push(l[0]);}
                else if(l[1]-a[l[0]]-a[s]!=0){able=false; break;}
                else if(!done[l[0]]){q.push(l[0]);}
            }
        }
        
        ll mi=E;
        for(int i=1;i<=n;i++){
            mi=min(mi,a[i]);
        }
        if(!able || mi<1){cout<<0<<endl;}
        else{cout<<1<<endl;}
    }
    
    
    
    return 0;
}

Measured memory_bytes: 20480
#include<iostream>
#include<vector>
#include<map>
using namespace std;
class UnionFind
{
    private:
        unsigned size_; std::vector<unsigned> par,rank;
    public:
        UnionFind():size_(0), par(std::vector<unsigned>()),rank(std::vector<unsigned>()){};
        UnionFind(unsigned size__):size_(size__)
        {
            par.resize(size_);rank.resize(size_);
            for(unsigned i=0;i<size_;i++)par[i]=i,rank[i]=0;
        }
        unsigned size(){return size_;}
        unsigned root(unsigned x){return par[x]==x?x:par[x]=root(par[x]);}
        bool same(unsigned x,unsigned y){return root(x)==root(y);}
        void unite(unsigned x,unsigned y)
        {
            x=root(x),y=root(y);
            if(x==y)return;
            if(rank[x]<rank[y])par[x]=y;
            else if(rank[x]==rank[y])par[y]=x,rank[x]++;
            else par[y]=x;
        }
        bool operator==(const UnionFind & u){return par==u.par;}
        bool operator!=(const UnionFind & u){return par!=u.par;}
};

int n,m,p,a,b;
main()
{
    cin>>p>>n>>m;
    UnionFind UF1(p+1),UF2(p+1);
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        UF1.unite(a,b);
    }
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        UF2.unite(a,b);
    }
    map<pair<int,int>,int> E;

    for(int i=1;i<=p;i++)E[make_pair(UF1.root(i),UF2.root(i))]++;

    for(int i=1;i<=p;i++)
    {
        if(i>=2)cout<<" ";
        cout<<E[make_pair(UF1.root(i),UF2.root(i))];
    }
    cout<<endl;    
    return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int sum;
    sum=a+b+c;
    if(sum==17)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;


    return 0;

}




Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
long long int a[200009];
int main()
{
    long long int n,res=0;
    scanf("%lld",&n);
    for(long long int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        a[i]-=i;
    }
    sort(a+1,a+n+1);
    long long int peep=a[n/2+1];
    for(long long int i=1; i<=n; i++)
        res+=abs(a[i]-peep);
    printf("%lld\n",res);
}


Measured memory_bytes: 1792
program ABC166C
    implicit none
    integer n,m,k,j(2),l,x
    integer,allocatable::a(:),b(:),c(:)
    read(*,*) n,m
    allocate(a(n),b(n),c(n))
    b(1:n)=0
    c(1:n)=0
    read(*,*) a(1:n)
    do k=1,m
        read(*,*) j(1:2)
        if(a(j(1))>a(j(2))) b(j(2))=b(j(2))+1
        if(a(j(2))>a(j(1))) b(j(1))=b(j(1))+1
        if(a(j(2))==a(j(1))) c(j(1:2))=c(j(1:2))+1
    end do
    x=0
    do l=1,n
        if(b(l)==0 .and. c(l)==0) x=x+1
    end do
    write(*,*) x
end program ABC166C

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010


const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int DP[MAX];

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

	REPS(x,1,100)REPS(y,x,100)REPS(z,y,100){
		int t = x*x + y*y + z*z + x*y + y*z + z*x;
		if (t > 10010)break;
		
		int c = (x==y) + (y==z) + (z==x);
		if(c == 0) DP[t]+=6;
		else if(c == 1 || c==2) DP[t] += 3;
		else DP[t] ++;
	}

	REPS(i,1,N+1)cout << DP[i] << endl;

	return 0;
}
 



Measured memory_bytes: 3652
import java.text.DecimalFormat;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double a, b, c, d, e, f, x, y;
		DecimalFormat df = new DecimalFormat("0.000");
		while(scan.hasNext()){
			a = scan.nextInt();
			b = scan.nextInt();
			c = scan.nextInt();
			d = scan.nextInt();
			e = scan.nextInt();
			f = scan.nextInt();
			
			x = (b*f-e*c)/(b*d-a*e);
			y = (a*f-d*c)/(a*e-b*d);
			if(x==-0)
				x=0;
			if(y==-0)
				y=0;
			System.out.println(df.format(x)+" "+df.format(y));
		}
	}
}

Measured memory_bytes: 18160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import java.lang.management.MemoryType;
import java.math.BigInteger;
import java.util.*;


public class Main {



        public static void main (String[]args) throws IOException {
        Scanner in = new Scanner(System.in);
        try(PrintWriter or = new PrintWriter(System.out)){

          int a= in.nextInt(),b=in.nextInt();
          double t=1.0*in.nextInt()+.5;
          double ans=0;
            for (double i = 1.0*a; i <=t; i+=(1.0*a)) {
                    ans+=b;
            }
            or.println((int)ans);





        }


    }


    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++) {
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec) {
                        f *= 10;
                    }
                }
            }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}

class prog {

    int skill;
    int indx;
    int pp;

    public prog(int skill, int indx) {
        this.skill = skill;
        this.indx = indx;
        pp = 0;
    }

    @Override
    public String toString() {
        return "prog{" + "skill=" + skill + ", indx=" + indx + ", pp=" + pp + '}';
    }

}

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

int main(){
    ll x;
    cin >> x;

    ll ans = 0;
    ll k = x / 500;
    ll m = x - 500 * k;
    ll n = m / 5;

    ans = k * 1000 + n * 5;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
int main(){
  while(1){
    char t;
    vector<int> s;
    int b=0,f=0;
    while(1){
      scanf("%c",&t);
      if(t=='.')break;
      b=1;
      if((t!='('&&t!=')'&&t!='['&&t!=']')||f==1)continue;
      else if(t=='(')s.push_back(1);
      else if(t=='[')s.push_back(2);
      else if(!s.empty()){
	if(s.back()==1&&t==')')s.pop_back();
	else if(s.back()==2&&t==']')s.pop_back();
	else f=1;
      }
      else if(t==']'||t==')')f=1;
    }scanf("%c",&t);
    if(b==0)break;
    else if(f==0&&s.empty())printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 1008
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        int[] copy = x.clone();
        Arrays.sort(copy);
        int first = copy[n / 2 - 1];
        int latter = copy[n / 2];
        for (int i = 0; i < n; i++) {
            if (x[i] <= first)
                System.out.println(latter);
            else
                System.out.println(first);
        }
    }
}


Measured memory_bytes: 91360
/*
AUTHOR : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com
*/

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050

#define ll long long
#define ld long double
#define lli long long int

#define pb emplace_back
#define INF 1000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define loop(i,n) for (lli i = 0; i < n; i++)
#define loopitr(xt,vec) for (auto xt : vec)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define itr :: iterator it
#define WL(t) while(t --)

#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define vi vector<lli>
#define seti set<lli>
#define pii pair<lli,lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.push_back(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvector(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";
#define printset(st) for(auto xt : st) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define endl '\n'

#define deb(x) cout<<#x<<" "<<x<<endl;

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}

bool isPrime(lli n){
if(n<=1) return false;
if(n<=3) return true;
if(n==5) return true;
if((n%2==0)||(n%3==0) || (n%5==0)) return false;
for(lli i=5;i*i<=n;i+=6)
    if((n%i==0)||(n%(i+2)==0))
        return false;
return true;
}

bool ispower2(lli n){
    return(n and (n&(n-1))==0 );
}

int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    lli n,k;
    cin>>n;
    lli a[n];
    scanarr(a,n);
    lli pre[n];
    lli suf[n];
    pre[0] = 0;
    suf[n-1] = 0;
    for(lli i=1;i<n;i++)
        pre[i] = pre[i-1]^a[i-1];
    
    for(lli i=n-2;i>=0;i--)
        suf[i] = suf[i+1]^a[i+1];
        
    //printarr(pre,n);
    //printarr(suf,n);
    
    loop(i,n)
        cout<<(pre[i]^suf[i])<<" ";
    
  } 
return 0;
}

Measured memory_bytes: 8296
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s[55],f;
int t[55];

int main(void){
	int n,i,ans=0;
	bool flag=false;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> s[i] >> t[i];
	}
	cin >> f;
	for(i=0; i<n; ++i){
		if(flag){
			ans += t[i];
		}
		if(f == s[i]){
			flag = true;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	int n;
	int a,t;
	int h[100010];
	double anst;
	int ans;
	int main(){
		read(n);read(t);read(a);
		for(R int i=1;i<=n;++i){
			read(h[i]);
			if(Abs(anst-a)>Abs(t-h[i]*0.006-a)||ans==0)anst=t-h[i]*0.006,ans=i;
		}
		cout<<ans;
		return 0;
	}
}
int main(){
	return Night::main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  rep(i,n+1){
    if(i%3==0 || i%5==0) continue;
    sum += i;
  }
  cout << sum << endl;
  return 0;
}


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

int main()
{
  int n,k;
  cin>>n>>k;
  long long int h[n];
  for(int i=0;i<n;i++)
  {
      cin>>h[i];
  }
  sort(h,h+n);
  long long int ans=0;
  for(int i=0;i<n;i++)
  {
    ans+=h[i];
  }
  if(k>=n){cout<<"0"<<endl;}
  else if(k==0){cout<<ans<<endl;}
  else
  {
      for(int i=n-1;i>=n-k;i--)
      {
          ans=ans-h[i];
      }
      cout<<ans<<endl;
  }
  
  
  
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    unsigned long long a;
    cin >> a;
    string b;
    cin >> b;
    int x = 100 * (b[0] - '0') + 10 * (b[2] - '0') + (b[3] - '0');
    cout <<(ll) ((a * x) / 100) << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    set<string> se;
    for(int len=1; len<=k; len++){
        for(int i=0; i<s.size()-len+1; i++){
            se.insert(s.substr(i, len));
        }
    }

    int id = 1;
    for(auto itr=se.begin(); itr!=se.end(); itr++){
        if(id == k){
            cout << *itr << endl;
            return 0;
        }
        id++;
    }
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#https://atcoder.jp/contests/abc084/tasks/abc084_c

n=ii()
carr,sarr,farr=[],[],[]

for _ in range(n-1):
    c,s,f=mii()
    carr.append(c)
    sarr.append(s)
    farr.append(f)

ans = [0]*n

for start in range(n-1):
    for temp in range(start,n-1):
        if ans[start]<sarr[temp]:
            ans[start]=carr[temp]+sarr[temp]
        else:
            aa= farr[temp]-(ans[start]%farr[temp])
            if aa==farr[temp]:
                aa=0
            ans[start]+=aa+carr[temp]
        #print(ans)
print(*ans)

Measured memory_bytes: 64364
#include<cstdio>
#include<cstring>
int main(void){
	char a[1500];
	for (int i = 0; scanf("%c", &a[i])!=EOF; i++){
		if (64< a[i] && a[i] <91 )printf("%c", a[i] + 32);
		else if (96< a[i] && a[i] <123)printf("%c", a[i] - 32);
		else printf("%c", a[i]);
	}

	return 0;
}

Measured memory_bytes: 2524