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

int main(){
    int N, M, Q;
    scanf("%d %d %d\n", &N, &M, &Q);
    vector<string> grid(N+1, "0");
    grid[0].resize(M);
    for (int i = 1; i <= N; i++) {
        char s[M];
        scanf("%s\n", s);
        grid[i] += s;
    }
    vector<vector<int>> psum(N+1, vector<int>(M+1, 0));
    vector<vector<int>> horsum(N+1, vector<int>(M+1, 0));
    vector<vector<int>> versum(N+1, vector<int>(M+1, 0));
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (grid[i][j] == '1') {
                psum[i][j]++;
                if (grid[i][j-1] == '1') horsum[i][j]++;
                if (grid[i-1][j] == '1') versum[i][j]++;
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            psum[i][j] += psum[i-1][j];
            horsum[i][j] += horsum[i-1][j];
            versum[i][j] += versum[i-1][j];
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            psum[i][j] += psum[i][j-1];
            horsum[i][j] += horsum[i][j-1];
            versum[i][j] += versum[i][j-1];
        }
    }
    
    for (int z = 0; z < Q; z++) {
        int x1, x2, y1, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        int ps = psum[x2][y2] - psum[x1-1][y2] - psum[x2][y1-1] + psum[x1-1][y1-1];
        int hors = horsum[x2][y2] - horsum[x1-1][y2] - horsum[x2][y1] + horsum[x1-1][y1];
        int vers = versum[x2][y2] - versum[x1][y2] - versum[x2][y1-1] + versum[x1][y1-1];
        printf("%d\n", ps - hors - vers);
    }
    
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned short int us;

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];

    vector<int> a(n);
    a[0] = 0;
    a[1] = abs(h[0] - h[1]);

    for (int i = 2; i < n; ++i)
        a[i] = min(a[i - 2] + abs(h[i - 2] - h[i]), a[i - 1] + abs(h[i - 1] - h[i]));

    cout << a[n - 1];
}























Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  int N;
  cin >> N;
  cout << N * N * N << endl;
}


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

int main(){
	int H,W;
	string mp[100];
	int ans[100][100];
	cin >> H >> W;
	for(int i = 0; i < H; i++){
		cin >> mp[i];
	}
	for(int i = 0; i < H; i++){
		int tmp = -1;
		bool isC = false;
		for(int j = 0; j < W; j++){
			if(mp[i][j] == 'c'){
				isC = true;
				ans[i][j] = 0;
				tmp = 0;
			}else {
				if(isC)tmp++;
				ans[i][j] = tmp;
			}
		}
	}	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(j == W-1)cout << ans[i][j] << endl;
			else cout << ans[i][j] << ' ';
		}
	}	
	
	return 0;
}


Measured memory_bytes: 3248
#include <stdio.h>

int main(){
  int x,y,d,i,k;
  scanf("%d%d",&x,&y);
  if(y>x){
    k=x;x=y;y=k;
  }
  while((x%y)!=0){
    k=x;x=y;y=k%y;
  }
  d=y;
  printf("%d\n",d);
  return 0;
}



Measured memory_bytes: 2048
require 'pp'

n, m = gets.chomp!.split(" ").map(&:to_i)

count = 0
if n * 2 <= m
    m -= (n*2)
    count = n
    n = 0
else
    n -= (m / 2)
    count = m / 2
    m = (m % 2 == 0 ? 0 : 1)
end

puts count + m / 4


Measured memory_bytes: 2300
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String previousWord = "";
        String nextword = "~";
        boolean isYes = true;

        Map resultMap = new HashMap();

        for(int i = 0; i<N; i++){

            nextword = sc.next();
            if(previousWord == ""){
                previousWord = nextword.substring(0,1);
            }

            if(previousWord.charAt(previousWord.length()-1) != nextword.charAt(0)){
                isYes = false;
                break;
            }
            if(resultMap.containsKey(nextword)){
                isYes = false;
                break;
            }
            resultMap.put(nextword,"");
            previousWord = nextword;
        }

        if(isYes){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <iomanip>

int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> numbers(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> numbers[i];
  }
  int64_t sum = 0;
  for (int i = 0; i < k; ++i) {
    sum += numbers[i];
  }
  int64_t max = sum;
  for (int i = k; i < n; ++i) {
    sum = sum - numbers[i - k] + numbers[i];
    max = sum > max ? sum : max;
  }
  std::cout << std::fixed << std::setprecision(8) << (static_cast<double>(max + k) / 2.0) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int a[5];
    rep(i,5)cin >> a[i];
    int res[5] = {0};
    rep(i,5){
       rep(j,5){
           if(j != i){
               res[i] += a[j];
               while(res[i]%10 != 0)res[i]++;
           }
       }
       res[i] += a[i]; 
    }
    
    cout << min({res[0],res[1],res[2],res[3],res[4]}) << endl;
    
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc123.contest.atcoder.jp/tasks/abc123_a

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

using namespace std;

int main() {
	vector<int> nums(3);
	cin >> nums[0] >> nums[1] >> nums[2];
	sort(nums.begin(),nums.end());
	cout << nums[2]*10+nums[1]+nums[0] << endl;
	return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
  return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
c = []
for i in range(h):
    c.append(list(input()))
ans = [[0] * w for i in range(h*2)]
for i in range(h):
    for j in range(w):
        ans[i*2][j] = c[i][j]
        ans[i*2+1][j] = c[i][j]
for i in range(h*2):
    print(''.join(ans[i]))

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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(u==s){
    a-=1;
  }
  else if(u==t){
    b-=1;
  }
  cout << a << " " << b << endl;
}

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

int main() {
  int n;cin>>n;
  vector<int>a(n),vec(n);
  rep(i,n-1){
    cin>>a[i];
    a[i]--;
    vec[a[i]]++;
  }
  rep(i,n)cout<<vec[i]<<endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int X, A; cin >> X >> A;
    if(X < A) cout << 0 << endl;
    else cout << 10 << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
def resolve():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

    ans = []
    if a[0] <= x:
        ans.append(a[0])
    else:
        ans.append(x)
    for i in range(1,n):
        if ans[i-1] + a[i] <= x:
            ans.append(a[i])
        else:
            ans.append(x-ans[i-1])
    print(sum(a)-sum(ans))

resolve()

Measured memory_bytes: 64228
class Dice:
    def __init__(self,d1,d2,d3,d4,d5,d6):
        self.dice = [d1,d2,d3,d4,d5,d6]
    def turn(self,dir):
        if dir == 'S':
            self.dice = [self.dice[4],self.dice[0],self.dice[2],self.dice[3],self.dice[5],self.dice[1]]
        if dir == 'N':
            self.dice = [self.dice[1],self.dice[5],self.dice[2],self.dice[3],self.dice[0],self.dice[4]]
        if dir == 'W':
            self.dice = [self.dice[2],self.dice[1],self.dice[5],self.dice[0],self.dice[4],self.dice[3]]
        if dir == 'E':
            self.dice = [self.dice[3],self.dice[1],self.dice[0],self.dice[5],self.dice[4],self.dice[2]]

dice_num = input().split()
direction = input()

init_Dice = Dice(dice_num[0],dice_num[1],dice_num[2],dice_num[3],dice_num[4],dice_num[5])
for a in range(len(direction)):
    init_Dice.turn(direction[a])
print(init_Dice.dice[0])



Measured memory_bytes: 5572
#ifndef LOCAL
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#else
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair


int main() {
    ios::sync_with_stdio(false);
    
    deque <char> q;
    string s;
    cin >> s;
    int t;
    cin >> t;
    bool r = false;
    for (int i = 0; i < len(s); i++)
    {
        q.pb(s[i]);
    }
    
    while (t--)
    {
        int f;
        cin >> f;
        if (f == 1){
            r = !r;
        } else {
            int t;
            cin >> t;
            char c;
            cin >> c;
            if (t == 1){
                if (r)
                    q.push_back(c);
                else
                    q.push_front(c);
            } else {
                if (r)
                    q.push_front(c);
                else
                    q.push_back(c);
            }
        }
        debug() << imie(q) << imie(r);
    }
    
    if (r)
        reverse(all(q));
    for (int i = 0; i < len(q); i++)
    {
        cout << q[i];
    }
    
}


Measured memory_bytes: 976
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 0;
        if (400 <= X && X < 600) {
            ans = 8;
        } else if (600 <= X && X < 800){
            ans = 7;
        } else if (800 <= X && X < 1000){
            ans = 6;
        } else if (1000 <= X && X < 1200){
            ans = 5;
        } else if (1200 <= X && X < 1400){
            ans = 4;
        } else if (1400 <= X && X < 1600){
            ans = 3;
        } else if (1600 <= X && X < 1800){
            ans = 2;
        } else if (1800 <= X && X < 2000){
            ans = 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35740
s=list(input())
#s=['l','e','l','v','l','e','l']
L=int((len(s)-1)/2)
f1=0
for i in range(L):
 #   print(s[0+i])
  #  print(s[len(s)-i-1])
    if s[0+i]==s[len(s)-i-1]:
        pass
   #     print('here1')
    else:
        f1+=1
    #    print('here2')

#print(f1)
LL=L//2
f2=0
if f1==0:
    for j in range(LL):
     #   print(s[0+j])
      #  print(s[L-j-1])
        if s[0+j]==s[L-j-1]:
            pass
 #           print('here3')
        else:
            f2+=1
  #          print('here4')
else:
    f2=1

#print(f1)
#print(f2)
if f1==0 and f2==0:
    print('Yes')
else:
    print('No')


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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if (a[0]==5 && a[1]==5 && a[2]==7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

typedef vector<int> vi;
typedef long long ll;

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

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    int p[a];
    for (int i = 0; i < a; i++) {
        cin >> p[i];
    }
    int q[b];
    for (int i = 0; i < b; i++) {
        cin >> q[i];
    }
    int r[c];
    for (int i = 0; i < c; i++) {
        cin >> r[i];
    }

    sort(p, p+a);
    reverse(p, p+a);
    sort(q, q+b);
    reverse(q, q+b);

    vi d;
    for (int i = 0; i < x; i++) {
        d.push_back(p[i]);
    }
    for (int i = 0; i < y; i++) {
        d.push_back(q[i]);
    }
    for (int i = 0; i < c; i++) {
        d.push_back(r[i]);
    }
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());

    ll ans = 0;
    for (int i = 0; i < x + y; i++) {
        ans += d[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a,b;
    cin>>a>>b;
    if(a*b%2==0) No;
    else Yes;
}

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

using namespace std;
typedef long long ll;
#define pi M_PI
#define gcd(a,b) __gcd(a,b)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fr first
#define sc second
#define pb push_back
#define in insert
#define mp make_pair
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define inmas(i,a,b,c)cin>>b;forr(i,a,b)cin>>c[i]
#define mod 1000000007
ll n,m,ans=0,k,s=0;
ll a[200000];
map<ll,ll> m1,m2;
map<ll,ll>::iterator iter;
int main()
{
cin>>n;
forr(i,0,n)cin>>a[i];
for(int i=0;i<n;i+=2)
m1[a[i]]++;
for(int i=1;i<n;i+=2)
m2[a[i]]++;
ll k1,k2;
k1=n/2;k2=k1;
ll mx=0,mm1=0,mm=0,mx1=0;
for(iter=m1.begin();iter!=m1.end();++iter)
{if(mx<(*iter).sc)mx=(*iter).sc,mm=(*iter).fr;}
for(iter=m2.begin();iter!=m2.end();++iter)
{if(mx1<(*iter).sc && mm!=(*iter).fr)mx1=(*iter).sc,mm1=(*iter).fr;}
ll g1,g2=n-mx1-mx;
mx=0,mm1=0,mm=0,mx1=0;
for(iter=m2.begin();iter!=m2.end();++iter)
{if(mx1<(*iter).sc )mx1=(*iter).sc,mm1=(*iter).fr;}
for(iter=m1.begin();iter!=m1.end();++iter)
{if(mx<(*iter).sc  && mm1!=(*iter).fr)mx=(*iter).sc,mm=(*iter).fr;}
g1=n-mx1-mx;
cout<<min(g1,g2)<<endl;
return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int ans=0;
  REP(i,N){
    if(S.substr(i,3)=="ABC")ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  ll n,k,s; cin >> n >> k >> s;

  if(k==0){
    if(s==pow(10,9)){
      FOR(i,0,n-1) cout << s-1 << " ";
    }
    else{
      FOR(i,0,n-1) cout << s+1 << " ";
    }

    return 0;
  }

  FOR(i,0,k-1) cout << s << " ";
  if(s==pow(10,9)){
    FOR(i,k,n-1) cout << s-1 << " ";
  }
  else{
    FOR(i,k,n-1) cout << s+1 << " ";
  }

  cout << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int alphabet[26] = {0};
    int H,W;
    cin >> H >> W;
    for ( int i = 0; i < H; i++ ) {
        string S;
        cin >> S;
        
        for ( auto& s : S ) {
            alphabet[ s - 'a' ]++;
        }        
    }
    
    int a = W%2;
    int b = W/2;
    
    int c = H%2;
    int d = H/2;
    
    int four = b*d;
    int two = a*d+c*b;
    int one = a*c;
    
    // cout << "four: " << four << endl;
    // cout << "two: " << two << endl;
    // cout << "one: " << one << endl;
    
    if ( H == 1 || W == 1 ) {
        int x = (H*W)%2;
        for ( int i = 0; i < 26; i++ ) {            
            if ( !alphabet[i] ) { continue; }
            if ( alphabet[i]%2 && x ) { x = 0; continue; }
            if ( alphabet[i]%2 && !x ) {
                cout << "No" << endl;  return 0;
            }
        }
        cout << "Yes" << endl; return 0;
    }
    
    for ( int i = 0; i < 26; i++ ) {        
        if ( !alphabet[i] ) { continue; }
        if ( alphabet[i]%2 && one ) {
            alphabet[i]--;
            one = 0;
            continue;
        }
        if ( alphabet[i]%2 && !one ) {
            cout << "No" << endl;  return 0;
        }
    }
    
    int f = 0;
    for ( int i = 0; i < 26; i++ ) {
        if ( alphabet[i] >= 4 ) {
            f += alphabet[i]/4;
        }
    }

    if ( four > f ) { cout << "No" << endl; return 0; }
    
    
    
    // for ( int i = 0; i < 26; i++ ) {
        // if ( !alphabet[i] ) { continue; }
        // if ( alphabet[i] >= 4 && four ) {
            // int x = max( 0, four-(alphabet[i]/4) );
            // alphabet[i] = x*4;
            // four = x;
        // }
    // }
    // if ( four ) { cout << "No" << endl;  return 0; }
    
    
    // for ( int i = 0; i < 26; i++ ) {
        // if ( !alphabet[i] ) { continue; }
        // if ( alphabet[i] >= 2 && two ) {
            // int x = max( 0, two-alphabet[i]/2 );
            // alphabet[i] = x*2;
            // two = x;
        // }
    // }
    // if ( two ) { cout << "No" << endl;  return 0; }
    
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
const int INF=1e9+7;
const int mod=1e9+7;
struct poi{
	int X;int Y;int Z;
  bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
//ACACACACACACACACACACACAC//
//WAWAWAWAWAWAWAWAWAWAWAWA//
//CECECECECECECECECECECECE//
//RERERERERERERERERERERERE//
//TLETLETLETLETLETLETLETLE//
//
int main(){
	int H,h;
	int K,k;
  int A,B,C,D;
	cin>>H>>h;
	cin>>K>>k;
	cin>>A>>B>>C>>D;
	int X=(H*A+h*B+H/10*C+h/20*D);
	int Y=(K*A+k*B+K/10*C+k/20*D);
	if(X==Y){
		cout<<"even"<<endl;
	}else if(X<Y){
		cout<<"kenjiro"<<endl;
	}else{
		cout<<"hiroshi"<<endl;
	}
	return 0;
}



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

using namespace std;

int main()
{
    int n;

    cin>>n;

    int d[n],sum=0;

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

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum = sum+(d[i]*d[j]);
        }
    }

    cout<<sum<<endl;

    return 0;
}


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

// https://atcoder.jp/contests/abc135/tasks/abc135_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] arrayN = new int[N];
		for(int i = 0;i<N;i++) {
			arrayN[i] = sc.nextInt();
		}
		sc.close();

		int[] sortArrayN = arrayN.clone();
		Arrays.sort(sortArrayN);

		int ans = 0;
		for(int i=0;i<arrayN.length;i++) {
			if(arrayN[i]!=sortArrayN[i]) {
				ans++;
			}
		}

		if(ans>2) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}

	}

}


Measured memory_bytes: 21716
N, K = map(int, input().split())

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

visitset = set()
visitcount = dict()
n_point = dict()

x = 1
count = 0
while(x not in visitset):
  visitset.add(x)
  visitcount[x] = count
  n_point[count] = x
  x = A[x-1]
  count += 1


period = count - visitcount[x]

if (K < visitcount[x]):
  print(n_point[K])
else:
  y = (K-visitcount[x]) % period
  print(n_point[visitcount[x] + y])



Measured memory_bytes: 56080
#include<iostream>
void insertionSort(int A[],int N){
  int i,j,key;
  for(i=1; i<N; i++){
      key=A[i];
      j=i-1;
      while(j>=0 && A[j]>key){
	A[j+1] = A[j];
	j--;
      }
      A[j+1] = key;
  }
}
int main(){
  int N;
  std::cin>>N;

  int A[N]={0};
  int i,j;
  for(i=0; i<N; i++){
      std::cin>>A[i];
  }
  for(j=1; j<=N; j++){
    insertionSort(A,j); 
    for(i=0; i<N-1; i++){
      std::cout<<A[i]<<" ";
    }
    std::cout<<A[N-1];
    std::cout<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int f(int r, int d, int x0, int &c) {
  int x1 = r * x0 - d; 
  cout << x1 << endl;
  c++;
  if(c<=10 ) {
    return f(r, d, x1, c);
  } else {
    return 0;
  }
}

int main() {
  int r, d, x0;
  cin >> r >> d >> x0;
  int c = 1;
  f(r, d, x0, c);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
#define vecvec(a) vector<vector<(a)>>
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

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

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M,r;
    cin >> N >> M >> r;
    struct edge{ll to,cost;};
    vector<edge> G[100005];
    ll a,b,c;
    rep(i,M){
        cin >> a >> b >> c;
        G[a].push_back({b,c});
    }
    vector<ll> dist(N,INF);
    dist[r] = 0;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push(P(0,r));
    while(que.size()){
        P p = que.top();que.pop();
        if(dist[p.second] < p.first)continue;
        for(auto x : G[p.second]){
            if(dist[x.to] > dist[p.second] + x.cost){
                dist[x.to] = dist[p.second] + x.cost;
                que.push(P(dist[x.to],x.to));
            }
        }
    }
    rep(i,N){
        if(dist[i] == INF){
            cout << "INF\n";
        }
        else cout << dist[i] << "\n";
    }
}



Measured memory_bytes: 19336
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
const ll MOD = 998244353;

vector<vector<int>> divs(1010101, vector<int>{});
vector<vector<int>> A_div(1010101, vector<int>{});
ll sum_AiAj[1010101];
vector<int> a(202020);

ll mod_pow(ll x, ll n){
    ll ret = 1;
    while(n!=0){
        if(n & 1){
            ret = ret * x % MOD;
        }
        x = x * x % MOD;
        n = n >> 1;
    } 
    return ret;
}

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

    int n; cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=1; i<1000001; i++){
        for(int j=1; i * j < 1000001; j++){
            divs[i * j].push_back(i);
        }
    }

    for(auto& v:a){
        for(auto& w:divs[v]){
            A_div[w].push_back(v);
        }
    }

    ll inv_mod2 = mod_pow(2, MOD-2);

    for(int i=0; i<1000001; i++){
        if((int)A_div[i].size() == 0){continue;}
        ll square_sum = 0;
        ll sum = 0;
        for(auto& v:A_div[i]){
            square_sum += 1LL * v * v;
            sum += v;
        }
        square_sum %= MOD;
        sum %= MOD;
        sum_AiAj[i] = (sum * sum - square_sum + MOD) % MOD;
        sum_AiAj[i] *= inv_mod2; 
        sum_AiAj[i] %= MOD;
    }

    ll ans = 0;
    for(int i=1000000; i>0; i--){
        ll val = sum_AiAj[i];
        for(int j=2; i * j<1000001; j++){
            val = (val - sum_AiAj[i*j] + MOD) % MOD;
        }
        sum_AiAj[i] = val;
        if(val == 0){continue;}
        ans += val * mod_pow(i, MOD-2);
        ans %= MOD;
    }
    cout << (ans + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 185836
#!/usr/bin/perl

my ($n,$k) = map { $_ - 0 } split(/\s+/,scalar(<STDIN>));
my $mb = 1000000007;

my $tot = 0;
for(my $i=$k; $i<=$n+1; $i++){
  my $p = ( $n * $i - $i * ( $i - 1 ) / 2 ) - ( $i * ( $i - 1 ) / 2 ) + 1;
  $tot = ( $tot + $p ) % $mb ;
}

print "$tot\n";



Measured memory_bytes: 4840
#

import sys
input=sys.stdin.readline

def main():
    MOD=10**9+7
    S=input().strip("\n")
    q=[]
    g=0
    S=S[::-1]
    m13=(1,10,9,12,3,4)
    for i in range(len(S)):
        if S[i] == "?":
            q.append(m13[i%6])
        else:
            x=int(S[i])
            g+=x*m13[i%6]
            g%=13
    if len(q)==0:
        if g==5:
            print(1)
        else:
            print(0)
        exit()
    N=len(q)
    q=[0]+q
    dp=[[0]*13 for i in range(N+1)]
    for j in range(10):
        dp[1][(j*q[1])%13]=1
    for i in range(2,N+1):
        for j in range(13):
            for k in range(10):
                x=(j-k*q[i])%13
                dp[i][j]+=dp[i-1][x]
                dp[i][j]%=MOD
    print(dp[N][(5-g)%13])
    
if __name__=="__main__":
    main()


Measured memory_bytes: 63776
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = (sc.nextInt() + 11) % 13;
		int b = (sc.nextInt() + 11) % 13;
		if (a > b) {
			System.out.println("Alice");
		} else if (a < b) {
			System.out.println("Bob");
		} else {
			System.out.println("Draw");
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include <vector>
#include <cmath>
#include<string>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

long func(long a,long b);
long long mcd(long long k,long long l);
const int R=2;

int main(){
    

    int n;
    cin>>n;
    
    
    cout<<mcd(R,n) <<endl;
    
    return 0;

}   

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

long long mcd(long long k,long long l){
    return (k/func(k,l))*l;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

void judge(int a, int b, int c){
	int ave = (a + b + c) / 3;
	if(a == 100 || b == 100 || c == 100 || (a + b) / 2 >= 90 || ave >= 80) {
		cout << 'A' << endl;
	}else if(ave >= 70 || (ave >= 50 && max(a, b) >= 80)){
		cout << 'B' << endl;
	}else{
		cout << 'C' << endl;
	}
}

int main(){
	int n;
	int pm, pe, pj;
	while(cin >> n && n){
		rep(i, n){
			cin >> pm >> pe >> pj;
			judge(pm, pe, pj);
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		String str=s.next();
		
		if(str.charAt(str.length()-1)=='s')
		{
			str=str+"es";
		}
		else
		{
			str=str+"s";
		}
		
		System.out.println(str);
		
	}
	
}

Measured memory_bytes: 38420
N = int(input()) #マスの数
H = list(map(int,input().split())) #各マスの高さ

move  = 0
max_move = 0

for i in range(N-1):
  if H[i] >= H[i+1]:
    move += 1
    if max_move <= move:
      max_move = move
  else:
    move = 0
print(max_move)
    

Measured memory_bytes: 15020
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<int, ll> i_ll;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 10;
double EPS = 1e-10;
double PI2 = M_PI * 2;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int H = ty - sy, W = tx - sx;

	cout << string(H, 'U');
	cout << string(W, 'R');

	cout << string(H, 'D');
	cout << string(W, 'L');

	cout << string(1, 'L');
	cout << string(H + 1, 'U');
	cout << string(W + 1, 'R');
	cout << string(1, 'D');

	cout << string(1, 'R');
	cout << string(H + 1, 'D');
	cout << string(W + 1, 'L');
	cout << string(1, 'U');

	cout << endl;
}


Measured memory_bytes: 256
A = []
for i in range(3):
    A.append([int(x) for x in input().split()])



N = int(input())

for i in range(N):
    b = int(input())

    for m in range(3):
        for n in range(3):
            if A[n][m] == b:
                A[n][m] = '○'

ans = 'No'

for i in range(3):
    if A[i][0] == A[i][1] and A[i][2] == A[i][1] and A[i][0] == '○':
        ans = 'Yes'
        
    if A[0][i] == A[1][i] and A[2][i] == A[1][i] and A[0][i] == '○':
        ans = 'Yes'

if A[0][0] == A[1][1] and A[2][2] == A[1][1] and A[0][0] == '○':
    ans = 'Yes'
    
if A[2][0] == A[1][1] and A[0][2] == A[1][1] and A[2][0] == '○':
    ans = 'Yes'

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

// graph template
template<typename T>
class edge{
    public:
        int src, to; T cost;

        edge(int to, T cost): src(-1), to(to), cost(cost){}
        edge(int src, int to, T cost): src(src), to(to), cost(cost){}
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

#ifndef GCD
#define GCD
// solve ax+by=gcd(a, b)
// return gcd(a, b)
template<typename T>
T gcd(const T a, const T b, T* const px = nullptr, T* const py = nullptr){
	if(py == nullptr){
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	T d = a;
	if(b != 0){
		d = gcd(b, a % b, py, px);
		*py -= (a / b) * *px;
	}else{
		*px = 1; *py = 0;
	}
	return d;
}
#endif

#ifndef LCM
#define LCM
// return lcm(a, b)
template<typename T>
T lcm(const T a, const T b){
	T ret = a / gcd(a, b);
	ret *= b;
	return ret;
}
#endif

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

    vector<ll> T(N);
    for(int i = 0; i < N; i++) cin >> T[i];

    ll res = 1;
    for(int i = 0; i < N; i++){
        res = lcm(res, T[i]);
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x,y,r,tmp;

    scanf("%d%d",&x,&y);

    if (x<y) {
        tmp=x;
        x=y;
        y=tmp;
    }

    while(1){
        r=x%y;
        if (r == 0) break;
        x=y;
        y=r;
    }
    printf("%d\n",y);

    return 0;
}



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

long long int GCD_Num(long long int a, long long int b)      //最大公约数
{
    long long int MAX=max(a,b);
    long long int MIN=min(a,b);
    long long int op;
    while(MAX%MIN!=0){
        op=MAX%MIN;
        MAX=MIN;
        MIN=op;
    }
    //cout<<MIN;
    return MIN;
}

void LCM_Num(long long int a, long long int b)
{
    long long int temp_lcm;
    temp_lcm=(a*b)/GCD_Num(a,b);
    cout<<GCD_Num(a,b)<<" "<<temp_lcm<<endl;
}

int main()
{
    long long int a,b;
    while(cin>>a>>b){
        GCD_Num(a,b);
        LCM_Num(a,b);
    }
    return 0;
}



Measured memory_bytes: 3032
using System;
using System.Linq;

class Plogram
{
    static void Main()
    {

        int num = int.Parse(Console.ReadLine());
        int[] height = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        int count = 1;
        int max = height[0];

        for (int i = 1;i<num;i++)
        {
            if(height[i] >= height[i-1] && height[i] >= max)
            {
                count++;
                max = height[i];
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13268
n=int(input())
a=list(map(int,input().split()))
a.sort()
y=a[-1]
diff=10**9+2
for i in a[:-1]:
    diff=min(diff,max(i,y-i))
x=-1
for i in a[:-1]:
    if max(i,y-i)==diff:
        x=i
        break
print(y,x)


Measured memory_bytes: 14056
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
ll sq3(int a){return 1LL*a*a*a;}
int main()
{
	int n,k;while(cin>>n>>k)
	{
		ll ans=sq3(n/k);
		if(k%2==0)
			ans+=sq3(2*n/k-n/k);
		cout<<ans<<Endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


// ----------------------------------------------------------------------------
int main(){
  string S;
  cin >> S;
  while(S != "-"){
    int m;
    cin >> m;
    for(int i=0; i<m; i++){
      int h;
      cin >> h;
      string pre,en;
      pre = S.substr(0,h);
      en = S.substr(h,S.size()-h);
      S = en + pre;
    }
    cout << S << endl;
    cin >> S;
  }
  return 0;
}



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

int main()
{
    unsigned long long X;
    cin >> X;

    unsigned long long year = 0;
    long long amount = 100;

    while (true)
    {
        amount *= 1.01;
        ++year;
        if (amount >= X)
        {
            break;
        }
    }

    cout << year;

    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int g(int x, int y) {
   int t;

   while ((t=x%y)!=0) {
      x=y;y=t;
   }
   return y;
}

int main(){
   int i,j,k,l,s,gcd[201][201];

   scanf("%d",&k);
   for (i=1;i<=k;i++)
      for (j=1;j<=k;j++) gcd[i][j]=g(i,j);
   s=0;
   for (i=1;i<=k;i++)
      for (j=1;j<=k;j++) 
        for (l=1;l<=k;l++) s+=gcd[gcd[i][j]][l];
   printf("%d\n",s);
   return 0;
}


Measured memory_bytes: 1844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 2000000009
#define init(x) memset(x,0,sizeof(x))
long long cnt[3][100005],a[3][100005],ans=0;
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=0;i<3;++i) for (int j=0;j<n;++j) cin>>a[i][j];
	sort(a[0],a[0]+n);
	sort(a[1],a[1]+n);
	sort(a[2],a[2]+n);
	for (int i=0;i<n;++i) cnt[2][i]=1;
	for (int i=1;i>=0;--i){
		int p=n-1;
		while(p>=0&&a[i+1][p]>a[i][n-1]){
			cnt[i][n-1]+=cnt[i+1][p];
			--p;
		}
		//cerr<<"i="<<i<<"  j="<<n-1<<"  cnt="<<cnt[i][n-1]<<endl;
		for (int j=n-2;j>=0;--j){
			cnt[i][j]=cnt[i][j+1];
			while(p>=0&&a[i+1][p]>a[i][j]){
				cnt[i][j]+=cnt[i+1][p];
				--p;
			}
			//cerr<<"i="<<i<<"  j="<<j<<"  cnt="<<cnt[i][j]<<endl;
		}
	}
	for (int i=0;i<n;++i) ans+=cnt[0][i];
	cout<<ans;
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int A, B, C;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,s1=0,s2=0,s3=0,i,x;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&x);
        if(x%4==0)
        s1++;
        else
        if(x%2==0)
        s2++;
        else
        s3++;
    }
    if(s2==0)
    {
        if(s1==0)
        {
            printf("No\n");
            return 0;
        }
        else
        if(s1+1>=s3)
        {
            printf("Yes\n");
            return 0;
        }
        else
        {
            printf("No\n");
            return 0;
        }
    }
    else
    if(s2==1)
    {
        s3=s3+s2;
        if(s1==0)
        {
            printf("No\n");
            return 0;
        }
        else
        if(s1+1>=s3)
        {
            printf("Yes\n");
            return 0;
        }
        else
        {
            printf("No\n");
            return 0;
        }
    }
    else
    if(s2>=2)
    {
        if(s1==0)
        {
            if(s3==0)
            {
                printf("Yes\n");
                return 0;
            }
            else
            {
                printf("No\n");
                return 0;
            }
        }
        else
        if(s1>=s3)
        {
            printf("Yes\n");
            return 0;
        }
        else
        {
            printf("No\n");
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 128