akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn a() {
    let s: String = read!(String);

    if &s == "Sunny" {
        println!("Cloudy");
        return;
    }
    if &s == "Cloudy" {
        println!("Rainy");
        return;
    }
    if &s == "Rainy" {
        println!("Sunny");
        return;
    }
}

fn b() {
    unimplemented!();
}

fn c() {
    unimplemented!();
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    a();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rgt register
#define rint rgt int
#define LL long long
#define rll rgt LL
#define inf 0x7f7f7f7f
#define N 200003
using namespace std;
template<class K>inline bool cmax(K&a,const K&b){return(a<b)?a=b,1:0;}
template<class K>inline bool cmin(K&a,const K&b){return(a>b)?a=b,1:0;}
inline int read() {
	rint s=0;
	rgt char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return s;
}
int n,k,a[N];
LL ans;
int main()
{
	rint i,j;
	n=read(),k=read();
	for(i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1),n=max(0,n-k);
	for(i=1;i<=n;i++) ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define sz(c) int(c.size())
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define vlong long long
map<int  , int> mp;
int main() {
	int n;
	cin >> n;
	int x;
	int mx = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d" , &x);
		mp[x]++;
		mp[x - 1]++;
		mp[x + 1]++;
		mx = max(mx , max(mp[x] , max(mp[x - 1] , mp[x + 1])));
	}
	cout << mx << endl;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll n,k;

    ll ans;

    Scll2(n,k);

    if( k % 2 ){
        ans = (n / k) * (n / k) * (n / k);
    }else{
        ans = (n / k) * (n / k) * (n / k);
        ans += ((n + k / 2) / k ) * ((n + k / 2) / k ) *  ((n + k / 2) / k );
    }

    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 256
S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"

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

print(N[K-1])

Measured memory_bytes: 2940
n, m = map(int, input().split())

s = []
for k in range(m):
    stdin = list(map(int, input().split()))
    s.append(stdin[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    i = bin(i)[2:].zfill(n)
    for k, si in enumerate(s):
        on_n = 0
        for sik in si:
            on_n += int(i[sik - 1])
        if on_n % 2 != p[k]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
const int MAX=3e5;
const int mod=1e9+7;
using namespace std;

int main(){
	int n , m, a, b, c;
	string s;
	cin>>s;
	set<int>st;
	int arr[27];
	memset(arr, 0 , sizeof(arr));
	for(int i=0;i<s.size();i++)
		st.insert(s[i]-'A');
	if(st.size()!=2)
		cout<<"No";
	else{
		sort(s.begin(),s.end());
		if(s[3]!=s[2]||s[0]!=s[1])
			cout<<"No";
		else
			cout<<"Yes";
	}

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k, c) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!

    fun f(s: String): List<Int> {
        val r = mutableListOf<Int>()
        var i = 0
        while (i < n && r.size < k) {
            if (s[i] == 'o') {
                r.add(i)
                i += c + 1
            } else {
                i++
            }
        }
        return r
    }

    val l = f(s).toIntArray()
    val r = f(s.reversed()).map { n - 1 - it }.reversed().toIntArray()

    (0 until k)
            .map { if (l[it] == r[it]) l[it] + 1 else 0 }
            .filter { it > 0 }
            .joinToString("\n")
            .let { println(it) }
}


Measured memory_bytes: 62264
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define vi           vector<ll>
#define pii          pair<ll,ll>
#define vpp          vector<pii>
#define mii          map<ll,ll>
#define pb           push_back
#define endl        '\n'
#define rep(i,a,bb)  for(ll i=a;i<bb;i++)
#define ff           first
#define ss           second
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test         ll T;cin>>T;while(T--)
#define __sort(v)    sort(v.begin(),v.end())
#define __rsort(v)   sort(v.rbegin(),v.rend())
#define setbits(x)   __builtin_popcount(x)
#define zrobits(x)   __builtin_ctzll(x)
const ll inf = 5 * (1e+18);
const ll mod = 7 + 1e+9;




int32_t main()
{
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif


  ll x ;
  cin >> x;
  ll p = 100.0;
  ll a = 100;
  ll c = 0;
  while (a < x)
  {
    c++;
    a = a + a / 100;

  }

  cout << c;





  return 0;
}





Measured memory_bytes: 3664
H, W = gets.split.map(&:to_i)


ans = Float::INFINITY

1.upto(H - 1) do |h|
  areaA = h * W
  w = (W / 2).ceil
  areaB = (H - h) * w
  areaC = (H - h) * (W - w)

  ans = [ans, [areaA, areaB, areaC].minmax.inject(:-).abs].min

  c = ((H - h) / 2).ceil
  areaD = c * W
  areaE = (H - h - c) * W

  ans = [ans, [areaA, areaD, areaE].minmax.inject(:-).abs].min
end

1.upto(W - 1) do |w|
  areaA = w * H
  h = (H / 2).ceil
  areaB = (W - w) * h
  areaC = (W - w) * (H - h)

  ans = [ans, [areaA, areaB, areaC].minmax.inject(:-).abs].min

  c = ((W - w) / 2).ceil
  areaD = c * H
  areaE = (W - w - c) * H

  ans = [ans, [areaA, areaD, areaE].minmax.inject(:-).abs].min
end

puts ans


Measured memory_bytes: 3836
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
var m=Arr.shift()-0;
var arr=[];
var max=m;
var sum=m;
for(var i=0;i<n;i++){
   var v=Arr.shift().split(" ").map(Number);
   sum+=(v[0]-v[1]);
   if(sum<0){max=0;break;}
   max=Math.max(max,sum);
}
console.log(max);

Measured memory_bytes: 12480
using System;

class Solution
{
    public string Proc(string val)
    {
        char before = ' ';
        foreach (var it in val)
        {
            if (before == it) return "Bad";
            before = it;
        }

        return "Good";
    }
}

class Program
{
    static string[] GetVals(string splitChar)
    {
        var src = Console.ReadLine();
        return src.Split(new string[] { splitChar }, StringSplitOptions.None);
    }

    static string[] GetVals(char splitChar)
    {
        var src = Console.ReadLine();
        return src.Split(splitChar);
    }

    static string GetVal()
    {
        return Console.ReadLine();
    }

    static void Write(object o)
    {
        Console.WriteLine(String.Format("{0}", o));
    }

    static int ParseI(string val) { return int.Parse(val); }
    static double ParseD(string val) { return double.Parse(val); }

    static void Main(string[] args)
    {
        var s = GetVal();
        Write(new Solution().Proc(s));

        //Write(new Solution().Proc("3776"));//B
        //Write(new Solution().Proc("8080"));//G
        //Write(new Solution().Proc("1333"));//B

        //GetVal();
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#define N 100
int main(){
  int i,j,k;
  int out[N][N],num,n,m[N][N];
  
  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      out[i][j] = 0;
    }
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d",&m[i][0],&m[i][1]);
    for(j=0; j<m[i][1]; j++){
      scanf("%d",&num);
      out[i][num-1] = 1;
    }
  }

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      if(j!=0) printf(" ");
      printf("%d",out[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 676
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
ll te[1000000];
int main() {
	ll n, c, k, t;
	cin >> n >> c >> k;
	ll sum = 0, o = -1;
	ll sum2 = 0;
	for (ll i = 0; i < n; i++)
		cin >> te[i];
	sort(te, te + n);
	for (ll i = 0; i < n; i++) {
		t = te[i];
		if (i == 0 || o + k < t || sum2 >= c) {
			o = t;
			sum++;
			sum2 = 1;
		}
		else
			sum2++;
	}
	cout << sum << endl;
	cin >> n;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;
    int n = s.length();
    int S = 0;
    for(int i = 0; i < n; ++i){
        S += (s[i] - '0');
        S %= 9;
    }
    if(S == 0)  cout << "Yes\n";
    else    cout << "No\n";
}

Measured memory_bytes: 3732
#include <stdio.h>
#include <math.h>
int abs(int n){
    if(n > 0){
        return n;
    } else {
        return -n;
    }
}


int main(){
  int n, x;
  scanf("%d %d", &n,&x);
  int l[n];
  for(int i = 0; i < n; i++){
      scanf("%d", &l[i]);
  }
 
  int d[n+1];
  for(int i = 0; i < n+1; i++){
      if(i==0){
          d[i] = 0;
      } else if(i==1){
          d[i] = l[i-1];
      } else {
          d[i] = d[i-1]+l[i-1];
      }
      // printf("%d ", d[i]);
  }

  int count = 0;
  for(int i = 0; i < n+1; i++){
      if(d[i] <= x){
          count++;
      }
  }
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  ll sta = 0;
  ll ans = 0;
  REP(i,s.size()){
      if(s[i]=='B'){
          sta++;
      }else{
          ans += sta;
      }
  }
  cout << ans << endl;

}

Measured memory_bytes: 1356
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

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

    int n;
    cin >> n;
    long long l, t;
    cin >> l >> t;

    vector<long long> pos(n), dir(n);
    vector<long long> final(n);

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

        if (dir[i] == 2)
            dir[i] = -1;

        final[i] = (pos[i] + dir[i] * t) % l;
        final[i] = (final[i] + l) % l;
    }

    auto target = final[0];

    sort(final.begin(), final.end());

    int where = 0;

    while (final[where] != target)
        where++;

    if (where + 1 < n && final[where + 1] == final[where])
        where++;

    int start = 0;

    for (int i = 0; i < n; ++i)
    {
        if (dir[i] != dir[0])
            start += 2;
    }

    start *= t / l;
    t %= l;

    for (int i = 0; i < n; ++i)
    {
        if (dir[i] != dir[0])
        {
            if (dir[0] == 1)
            {
                if (pos[i] - pos[0] + l <= 2 * t)
                {
                    start += 2;
                }
                else if (pos[i] - pos[0] <= 2 * t)
                {
                    start++;
                }
            }
            else
            {
                if (pos[0] + l - pos[i] + l < 2 * t)
                {
                    start += 2;
                }
                else if (pos[0] + l - pos[i] < 2 * t)
                {
                    start++;
                }
            }
        }
    }

    start %= n;
    if (dir[0] == -1)
        start = n - start;
    start %= n;

    where -= start;
    where += n;
    where %= n;

    for (int i = 0; i < n; ++i)
    {
        cout << final[(where + i) % n] << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	int five = 0;
	int seven = 0;
	if (A == 5) {
		five++;
	}
	else if (A == 7) {
		seven++;
	}

	if (B == 5) {
		five++;
	}
	else if (B == 7) {
		seven++;
	}

	if (C == 5) {
		five++;
	}
	else if (C == 7) {
		seven++;
	}

	if (five == 2 && seven == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}






Measured memory_bytes: 3580
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;


int main() {
	string s;
	cin >> s;
	ll value = 0;
	for(char c : s) {
		value = (c - '0') + value;
	}

	if (value % 9 == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3356
// https://atcoder.jp/contests/abc079/tasks/abc079_d?lang=en

#include <bits/stdc++.h>

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {
  int h, w;
  int c[10][10];
  scanf("%d %d", &h, &w);
  for (int i=0; i<10; i++) {
    for (int j=0; j<10; j++) {
      scanf("%d", &c[i][j]);
    }
  }

  // Warshall-Floyd algorithm
  for (int k=0; k<10; k++) {
    for (int i=0; i<10; i++) {
      for (int j=0; j<10; j++) {
        if (c[i][j] > c[i][k]+c[k][j])
          c[i][j] = c[i][k]+c[k][j];
      }
    }
  }

  int a=0;
  int ans=0;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      scanf("%d", &a);
      if (a>=0) ans += c[a][1];
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        int rc[][] = new int[r][c];
        int c_total = 0;
        int r_total[] = new int[c + 1];

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                int num = sc.nextInt();
                rc[i][j] = num;
            }
        }
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                c_total += rc[i][j];
                r_total[j] += rc[i][j];
                System.out.print(rc[i][j]);
                System.out.print(" ");
            }
            r_total[c] += c_total;  
            System.out.println(c_total);
            c_total = 0;
        }
        for(int i = 0; i < c + 1; i++){
        System.out.print(r_total[i]);
        if(i != c){
            System.out.print(" ");
        }
        }
        System.out.println("");
    }
}

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

void solve(){
    string s,t;
    long long ans=0;
    cin>>s;
    cin>>t;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
            ans+=1;
    }
    cout<<ans<<endl;
}

int main()
{
    int t;
    solve();
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (1) {
        c -= b;
        if (c < 1) {
            puts("Yes");
            return 0;
        }
        a -= d;
        if (a < 1) {
            puts("No");
            return 0;
        }
    }
}

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

int pow(int a,int n) {
    int ans = 1;
    rep(i,n) ans *= a;
    return ans;
}

int main() {
    int N; cin >> N;
    vector<int> beki;
    beki.push_back(1);
    for(int i = 2; i <= N; i++) {
        int p = 2;
        bool ok = false;
        while(pow(i,p) <= N) {
            ok = true;
            beki.push_back(pow(i,p));
            p++;
        }
    }
    std::vector<int>::iterator iter = std::max_element(beki.begin(), beki.end());
    //for(auto x: beki) cout << x << " " << endl;
    cout <<  *iter << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll X, Y;
    cin >> X >> Y;

    ll ans = 1;
    while(X<=Y){
        X *= 2;
        if(X>Y) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {
        
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());

            var dic = new Dictionary<string, int>();
            for(int i = K; i >= 1; i--)
            {
                for(int j = 0; j <= S.Length - i; j++)
                {
                    //Console.WriteLine($"({i}, {j})");
                    string s = S.Substring(j, i);
                    //Console.WriteLine($"s = {s}");
                    if (!dic.ContainsKey(s)) dic[s] = 1;
                }
            }            

            var sort_dic = dic.OrderBy(x => x.Key);
            int cnt = 0;
            foreach(var p in sort_dic)
            {
                cnt++;
                if (cnt == K)
                {
                    Console.WriteLine(p.Key);
                }
            }



        }
    }
}

Measured memory_bytes: 13536
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define maxn 200010
int a[maxn];
using namespace std;

int main()
{
    int n,k,mavx=-2000000000,mivn;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }

    mivn=a[1];

    for(int i=2;i<=n;i++)
    {
        mavx=max(a[i]-mivn,mavx);
        mivn=min(a[i],mivn);
    }

    printf("%d\n",mavx);
    return 0;
    }

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

using namespace std;

int main(){
    int k;
    cin >> k;
    string t;
    cin >> t;
    int n;
    n = t.size();
    string s = "...";
    
    if(n<=k)
        cout<<t;
    else
    {
        for(int i=0;i<k;i++)
            cout<<t[i];
        cout<<s;
    }
    
}

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

const string cindex="ABWXYZS";
const string next[]={"XY","YX","BY","SZ","XS","WB","SS"};

int getCityIndex(char c){
	for(int i=0;i<cindex.size();++i) if(cindex[i]==c) return i;
}
int main(void){
	string s;
	while(cin>>s,s!="#"){
			char c='A';
			for(int i=0;i<s.size();++i){
				c=next[getCityIndex(c)][s[i]-'0'];
			}
			cout<<((c=='B')?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string  a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> max(n);
  int ans = 0;

  for (int i = 0; i < n; i++) {
    vector<int> word(26);
    word[a[i] - 'a']++;
    word[b[i] - 'a']++;
    word[c[i] - 'a']++;
    ans += 3 - *max_element(word.begin(), word.end());
  }

  cout << ans << "\n";
  return 0;
}

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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(16);
    cin.tie(0); ios::sync_with_stdio(false);

    string s;
    cin >> s;
    ll n = s.size();
    ll r = 0;
    for(ll i=0; i<n; i++)
        if(i&1)
            r += s[i]=='g';
        else
            r -= s[i]=='p';
    cout << r << endl;
}


Measured memory_bytes: 512
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var nhw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Enumerable.Repeat(0, nhw[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).Count(x => nhw[1] <= x[0] && nhw[2] <= x[1]));
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
#define make_pair mk
typedef pair<int, int> P;

int main(){
	string input;
	map<string, P> data;
	int maxlen = 0, maxcnt= 0;
	string lenst, cntst;
	while( cin >> input ){	
		if( data.find(input) == data.end() ){
			data.insert( pair<string, P>(input, P(input.size(), 1)) );
			//maxlen = max(maxlen, (int)input.size());
			if( maxlen < input.size() ){
				maxlen = input.size();
				lenst = input;
			}
		}else{
			//data[input].second++;
			if( maxcnt < data[input].second++ ){
				maxcnt = data[input].second;
				cntst = input;
			}
		}
	}
	/*map<string, P>::iterator it = data.begin();
	for( ; it != data.end(); it++ ){
		cout << (*it).first << "," << (*it).second.first << "," << (*it).second.second << endl;
	}*/
	cout << cntst << " " << lenst << endl;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

long long MOD = 1000000007LL;

template<class T>
vector<T> dijkstra(vector<vector<int>> E, vector<vector<T>> W, int s, T inf, vector<long long> &pat)
{
    int n = (int)E.size();

    for (int i=0; i<n; i++)
        pat[i] = 0;

    vector<T> D(n, inf);
    typedef pair<T,int> P;
    priority_queue<P,vector<P>,greater<P>> Q;

    D[s] = T();
    pat[s] = 1;
    Q.push(make_pair(D[s], s));

    while (!Q.empty())
    {
        long long d = Q.top().first;
        int p = Q.top().second;
        Q.pop();
        if (d > D[p])
            continue;
        for (int i=0; i<(int)E[p].size(); i++)
        {
            int t = E[p][i];
            if (d+W[p][i] < D[t])
                D[t] = d+W[p][i],
                pat[t] = 0LL,
                Q.push(make_pair(D[t], t));
            if (d+W[p][i]==D[t])
                pat[t] = (pat[t]+pat[p])%MOD;
        }
    }
    return D;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin>>N>>M;
    int S, T;
    cin>>S>>T;
    S--, T--;
    vector<vector<int>> E(N);
    vector<vector<long long>> D(N);
    for (int i=0; i<M; i++)
    {
        int u, v;
        long long d;
        cin>>u>>v>>d;
        E[u-1].push_back(v-1);
        E[v-1].push_back(u-1);
        D[u-1].push_back(d);
        D[v-1].push_back(d);
    }
    vector<long long> DS(N), DT(N), PS(N), PT(N);
    long long oo = 10000000000LL*N;
    DS = dijkstra(E, D, S, oo, PS);
    DT = dijkstra(E, D, T, oo, PT);

    long long ans = PS[T]*PS[T]%MOD;
    for (int i=0; i<N; i++)
    for (int j=0; j<(int)E[i].size(); j++)
        if (DS[i] + D[i][j] + DT[E[i][j]] == DS[T])
            if (DS[i]*2 < DS[T] && DS[T] < DS[E[i][j]]*2)
                ans -= PS[i]*PS[i]%MOD*PT[E[i][j]]%MOD*PT[E[i][j]]%MOD;
    for (int i=0; i<N; i++)
        if (DS[i] + DT[i] == DS[T] && DS[i]*2==DS[T])
            ans -= PS[i]*PS[i]%MOD*PT[i]%MOD*PT[i]%MOD;
    cout<<(ans%MOD+MOD)%MOD<<endl;
}


Measured memory_bytes: 34272
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

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

    static class AtA {
        private final FastScanner in;
        private final PrintWriter out;

        public AtA(FastScanner in, PrintWriter out) {
            this.in = in;
            this.out = out;
        }

        public void solve(int testNumber) {
            String a = in.next();
            out.println(a.matches(".*C.*F.*") ? "Yes" : "No");

        }

    }

    static class FastScanner {
        private final static int BUFFER_SIZE = 4096;
        private final InputStream in;
        private final StringBuilder sb = new StringBuilder();
        private byte[] buffer = new byte[BUFFER_SIZE];
        private int pos = 0;
        private int size;

        public FastScanner(InputStream inputStream) throws IOException {
            in = inputStream;
            size = 0;
        }

        public String next() {
            int c = skipWhitespace();
            if (c == -1) {
                return null;
            }

            sb.setLength(0);

            do {
                sb.append((char) c);
                c = read();
            } while (c > ' ');

            return sb.toString();
        }

        private int skipWhitespace() {
            while (true) {
                int c = read();
                if (c > ' ' || c == -1) {
                    return c;
                }
            }
        }

        private int read() {
            if (pos >= size) {
                try {
                    size = in.read(buffer, 0, BUFFER_SIZE);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (size <= 0) {
                    return -1;
                }
                pos = 0;
            }
            return buffer[pos++];
        }

    }
}



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

struct StCoord
{
  StCoord() : m_nx(0), m_ny(0) { }

  int m_nx;
  int m_ny;
};

void fnInput(vector<StCoord>& rvoCoord)
{
  int nCrdSiz;
  cin >> nCrdSiz;
  rvoCoord.resize(nCrdSiz);

  for (StCoord& roCoord : rvoCoord)
    cin >> roCoord.m_nx >> roCoord.m_ny;
}

double fnDistGet(int nFrom, int nTo, const vector<StCoord>& cnrvoCoord)
{
  int nDistx = cnrvoCoord[nFrom].m_nx - cnrvoCoord[nTo].m_nx;
  int nDisty = cnrvoCoord[nFrom].m_ny - cnrvoCoord[nTo].m_ny;

  return sqrt(nDistx * nDistx + nDisty * nDisty);
}

double fnAveDistGet(const vector<StCoord>& cnrvoCoord)
{
  double nTotalDist = 0.0;
  int nTotalCnt = 0;

  vector<int> vnCity(cnrvoCoord.size());
  iota(begin(vnCity), end(vnCity), 0);

  do {
    for (int n = 0; n < cnrvoCoord.size() - 1; n++)
      nTotalDist += fnDistGet(vnCity[n], vnCity[n + 1], cnrvoCoord);
      nTotalCnt++;
  }
  while ( next_permutation(begin(vnCity), end(vnCity)) );

  return nTotalDist / nTotalCnt;
}

int main()
{
  vector<StCoord> voCoord;

  fnInput(voCoord);
  cout << fixed << setprecision(10) << fnAveDistGet(voCoord) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main() {
    string S;
    cin >> S;
    int K;
    cin >> K;
    int tmp = 1, left = 1;
    int size = S.size();
    if (size == 1) {
        printf("%d\n", K / 2);
        return 0;
    }
    for (int i = 1; i < size; ++i) {
        if (S[i] == S[i - 1]) {
            tmp += 1;
        } else {
            if (i == tmp) left = tmp;
            ans += tmp / 2;
            tmp = 1;
        }
    }
    if (size == tmp) left = tmp;
    ans += tmp / 2;
    ans *= K;
    if (S[0] == S[size - 1] && tmp % 2 == 1 && left % 2 == 1) {
        if (size == left) {
            ans += K / 2;
        } else {
            ans += K - 1;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
//typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct Edge{
    int to,cost;
};

signed main (){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    cout<<(h%a*w) + (w%b*h) - ((h%a)*(w%b))<<endl;

}


/*
*/


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)j; i<(int)n; i++)
int main() {
  int k,s,ans=0; cin>>k>>s;
  rep(x,0,k+1){
    rep(y,0,k+1){
      if(s-x-y>=0&&s-x-y<=k) ans++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	string S;
	cin>>S;
	
	char ans='X';
	int l=(int)S.length();
	
	for(char i='a';i<='z';i++){
		bool find=false;
		rep(j,l){
			if(S[j]==i)find =true;
		}
		if(!find){
			ans=i;
			break;
        }
	}
    if(ans=='X') cout<<"None";
	else cout<<ans;
	
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
int main()
{
	int n,i,l[205];
	while(~scanf("%d",&n))
	{int ans=0;
	 for(i=0;i<2*n;i++)
	 scanf("%d",&l[i]);
	 using namespace std;
	 sort(l,l+2*n);
	 for(i=0;i<2*n;i+=2)
	 {ans+=l[i];
	 }
	 printf("%d\n",ans);
	}
}

Measured memory_bytes: 128
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 c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int f = sc.nextInt();
    int[] water = new int[(f / 100) + 1];
    int[] sugar = new int[f + 1];

    for(int i = 0; i < water.length; i++) {
      for(int j = 0; j < water.length; j++) {
        if((a * i + b * j) < water.length) water[a * i + b * j] = 1;
      }
    }

    for(int i = 0; i < sugar.length; i++) {
      for(int j = 0; j < sugar.length; j++) {
        if((c * i + d * j) < sugar.length) sugar[c * i + d * j] = 1;
      }
    }

    int satousui = 0;
    int satou = 0;
    double per = -1;

    for(int i = 1; i < water.length; i++) {
      for(int j = 0; j < sugar.length; j++) {
        if((water[i] == 1) && (sugar[j] == 1)) {
          if(100 * i + j <= f) {
            if(j <= e * i) {
              if(((double)j / (double)i) > per) {
                per = (double)j / (double)i;
                satousui = 100 * i + j;
                satou = j;
              }
            }
          }
        }
      }      
    }

    System.out.print(satousui);
    System.out.print(" ");
    System.out.println(satou);
  }
}


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

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

using namespace std;

int main(void) {
	int h,w;
	cin >> h >> w;

	vector<vector<int>> c(10,vector<int>(10,0));
	rep(i, 10) rep(j, 10) {
		cin >> c[i][j];
	}
	vector<vector<int>> wall(h,vector<int>(w,0));
	rep(i, h) rep(j, w) {
		cin >> wall[i][j];
	}

	rep(k, 10) rep(i, 10) rep(j, 10) {
		if (c[i][j] > c[i][k] + c[k][j]) c[i][j] = c[i][k] + c[k][j];
	}
  
	int ans = 0;
	rep(i, h) rep(j, w) {
		if (wall[i][j] >= 0) ans += c[wall[i][j]][1];
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Abc164B
    {
        public static void Main()
        {
            var abcd = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var hp0 = abcd[0];
            var atk0 = abcd[1];
            var hp1 = abcd[2];
            var atk1 = abcd[3];
            var turn0 = hp1 / atk0 + (hp1 % atk0 != 0 ? 1 : 0);
            var turn1 = hp0 / atk1 + (hp0 % atk1 != 0 ? 1 : 0);
            Console.WriteLine(turn0 <= turn1 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 19008
#include<iostream>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int h[N];
  int ans = 0;
  for(int i=0; i<N; i++){
    cin >> h[i];
    if(h[i]>=K) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
# cf17-finalB - Palindrome-phobia
from collections import Counter


def main():
    S = input().rstrip()
    C = Counter(S).values()
    flg = [len(C) == 1 and sum(C) == 1]  # e.g. "a"
    flg += [len(C) == 2 and sum(C) == 2]  # "ab"
    flg += [len(C) == 3 and max(C) - min(C) <= 1]  # "abcab"
    print("YES" if any(flg) else "NO")


if __name__ == "__main__":
    main()

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

int main(){
  int n, k; cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());
  
  int ans = 1000000000;
  
  for(int i = 0; i < n-k+1; i++){
  	ans = min(ans, h[i+k-1]-h[i]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b; cin>>a>>b;
    if(a*b%2!=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
#define pi 3.14159265358979

int main()
{
    double a,b,x;
    cin >> a >> b >> x;
    double area = x/a;
    //cout << a << ", " << b << ", " << x << endl;
    double half = (a*b)/2.0; 
    
    double theta = 0.0;
    if(half >= area){
        double height = b;
        double base = area / height * 2.0;
        //cout << area  << ", " << half << ", " << height<< endl;
        theta = atan(height/base) * (180.0/pi);
    }else{
        double remain = (a*b) - area;
        double base = a;
        double height = remain / base * 2.0;
        //cout << remain  << ", " << half << ", " << height<< endl;
        theta = atan(height/base) * (180.0/pi);
    }
    //cout << theta << endl;
    printf("%.7lf\n", theta);
    
    return 0;
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x, y;
	cin >> x >> y;
	if (y >= 2 * x && y <= 4 * x && y % 2 == 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
 	return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	
	cin>>N;
	
	for(int i = 1; i < 2*N; i++){
		int x = (i * 108)/100;
		
		if(x == N){
			cout<<i<<endl;
			return 0;
		}
	}
	
	cout<<":("<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;
//const int mod = 1000000007;
const int mod = 998244353;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
    return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    mint ans = 0;
    mint col = m;
    combination c(200005);
    for(int x = n-1;x>=0;--x){
        mint now = col;
        now *= c(n-1,x);
        if(x <= k) ans += now;
        col *= m-1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint n;
  cin >> n;
  if (n & 1) {
    cout << 0 << endl;
  } else {
    lint cnt = 0;
    for (lint base = 5; base <= n; base *= 5) {
      cnt += n / base / 2;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long a=2,b,t,p,s,h;
	scanf("%d",&b);
	s=a*b;
	if(a<b)
	{
		t=b;
	    b=a;
		a=t;
	}
	while(p=a%b,p!=0)
	{
       a=b;
	   b=p;
	}
	h=s/b;
	printf("%d\n",h);
	return 0;
}


Measured memory_bytes: 128
s = input()
d = {"N":0,"W":0,"S":0,"E":0}

for c in s:
    d[c] += 1
flag = True
if d["N"] > 0:
    if d["S"] <= 0:
        flag = False
if d["S"] > 0:
    if d["N"] <= 0:
        flag = False
if d["W"] > 0:
    if d["E"] <= 0:
        flag = False
if d["E"] > 0:
    if d["W"] <= 0:
        flag = False


if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			final double EPS = 1e-10;
			double bestValue = 0;
			int bestId = -1;
			for (int iii = 0; iii < n; iii++) {
				int id = sc.nextInt();
				double h = sc.nextDouble() / 100.0;
				double w = sc.nextDouble();
				double value = Math.abs(22 - w / (h * h));
				if (bestId == -1 || 
					bestValue > value + EPS ||
					(Math.abs(bestValue - value) < EPS && bestId > id) 
				) {
					bestValue = value;
					bestId = id;
				}
			}
			System.out.println(bestId);
		}
	}
}

Measured memory_bytes: 36896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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 burger(ll n,ll x){
  if(n==0) return 1;
  ll len = (1LL<<(n+2)) - 3;
  ll pat = (1LL<<(n)) -1;


  // cout << "------------" << endl;
  // cout << n << " " << pat << endl;
  // cout << x << " " << len << endl;

  --x;

  if(x==0) return 0;
  else if(x <= len/2 - 1) return burger(n-1,x);
  else if(x == len/2) return pat + 1;
  else if(x <= len - 2) return pat + 1 + burger(n-1,x-len/2);
  else return pat * 2 + 1;

}


int main() {
  ll N,X;
  scanf("%lld%lld", &N,&X);

  cout << burger(N,X) << endl;

}



Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a[200000+5];
ll b[200000+5];
ll mabs(ll x)
{
    if(x<0) return x*-1;
    return x;
}
int main()
{
    int n;
    scanf("%d",&n);
    ll _min=0;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        a[i]-=(i+1);
        _min+=mabs(a[i]);
    }
    sort(a,a+n);
    b[0]=a[0];
    for(int i=1;i<n;i++)
    {
        b[i]=b[i-1]+a[i];
    }
    _min=min(_min,b[n-1]-b[0]-(n-1)*a[0]);
    for(int i=1;i<n;i++)
    {
        _min=min(_min,mabs(b[i-1]-i*a[i])+b[n-1]-b[i-1]-(n-i)*a[i]);
    }
    printf("%lld\n",_min);
    return 0;
}


Measured memory_bytes: 3328