akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn readu32(&mut self) -> u32 {
        self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .fold(0, |acc, x| acc*10 + (x as u8 - b'0') as u32)
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn insertion_sort(a: &mut Vec<u32>, g: usize) -> usize {
    let mut cnt = 0;
    let n = a.len();
    for i in g..n {
        let v = a[i];
        let mut j = i;
        while j >= g && a[j-g] > v {
            a[j] = a[j-g];
            cnt += 1;
            j -= g;
        }
        a[j] = v;
    }
    cnt
}

fn shell_sort(a: &mut Vec<u32>, g: &[usize]) -> usize {
    let mut cnt = 0;
    for &i in g.iter() {
        cnt += insertion_sort(a, i);
    }
    cnt
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n = sc.read();
    let mut a: Vec<_> = (0..n).map(|_| sc.readu32()).collect();

    let g = {
        let mut g = vec![];
        let mut x = 1 as usize;
        while x <= n {
            g.push(x);
            x = x*3 + 1;
        }
        g.reverse();
        g
    };

    let cnt = shell_sort(&mut a, &g[..]);
    let stdout = stdout();
    let stdout = stdout.lock();
    let mut stdout = BufWriter::new(stdout);

    writeln!(&mut stdout, "{}", g.len()).unwrap();
    for x in g.iter() {
        writeln!(&mut stdout, "{}", x).unwrap();
    }
    writeln!(&mut stdout, "{}", cnt).unwrap();
    for x in a.iter() {
        writeln!(&mut stdout, "{}", x).unwrap();
    }
}



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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;
const int maxn = 25100;
const int maxk = 405;

int add(int a, int b) { return (a + b) % mod; }
int sub(int a, int b) { return a<b ? a+mod-b : a-b; }
int mult(int a, int b) { return ll(a) * b % mod; }
int exp(int b, int e) {
    if (!e) return 1;
    if (e&1) return mult(b, exp(b, e-1));
    int res = exp(b, e>>1);
    return mult(res, res);
}

int N, K, M, A[maxn];
int C[maxk][maxk];
int dp[maxn][maxk], pre[maxn][maxk];

int freq[maxk];

bool A_colorful() {
    for (int i = 0; i <= M - K; i++) {
        memset(freq, 0, sizeof(freq));
        bool good = 1;
        for (int j = i; j < i + K; j++) {
            if (freq[A[j]]) { good = 0; break; }
            else freq[A[j]]++;
        }
        if (good) return 1;
    }
    return 0;
}

bool A_dup() {
    memset(freq, 0, sizeof(freq));
    for (int i = 0; i < M; i++) {
        if (freq[A[i]]) return 1;
        else freq[A[i]]++;
    }
    return 0;
}

int A_kl() {
    memset(freq, 0, sizeof(freq));
    for (int i = 0; i < M; i++) {
        if (freq[A[i]]) return i;
        else freq[A[i]]++;
    }
    return M;
}

int get_noncolorful() {
    if (A_colorful()) return 0;
    if (A_dup()) {
        int kl = A_kl();
        reverse(A, A + M);
        int kr = A_kl();
        reverse(A, A + M);

        int ret = 0;
        for (int l = 0; l <= N-M; l++) {
            int r = N-M-l;
            ret = add(ret, mult(dp[l][kl], dp[r][kr]));
        }
        return ret;
    }

    // A not colorful, no duplicates
    
    int ret = 0;
    for (int l = 0; l <= N-M; l++) {
        int r = N-M-l;
        for (int m = 0; m <= min(K-M, l); m++) {
            int l2 = l-m-1;
            int kr = M+m;

            int num = mult(dp[r][kr], C[K-M][m]);
            if (l2 < 0) ret = add(ret, num);
            else ret = add(ret, mult(num, pre[l2][m+M]));
        }
    }

    return ret;
}

int main() {
    ios_base::sync_with_stdio(0);

    cin >> N >> K >> M;
    for (int i = 0; i < M; i++) cin >> A[i];

    for (int a = 0; a <= K; a++) {
        int cur = 1;
        C[a][0] = 1;
        for (int b = 1; b <= a; b++) {
            cur = mult(cur, a-b+1);
            C[a][b] = cur;
        }
    }

    for (int k = 0; k < K; k++) dp[0][k] = 1;
    for (int n = 1; n <= N; n++) {
        int sum = 0;
        for (int k = 0; k < K; k++) {
            if (k > 0) sum = add(sum, dp[n-1][k]);
            dp[n][k] = add(sum, mult(K-k, dp[n-1][k+1]));
        }
    }

    for (int n = 0; n <= N; n++)
        for (int k = 1; k <= K; k++)
            pre[n][k] = add(dp[n][k], pre[n][k-1]);

    int tot = mult(N-M+1, exp(K, N-M));
    cout << sub(tot, get_noncolorful()) << endl;
}

Measured memory_bytes: 80384
#!/usr/bin/env python3

import sys

input = iter(sys.stdin.read().splitlines()).__next__


sys.setrecursionlimit(10000)

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

res = len([1  for i in range(N) if i % 2 == 0 and A[i] % 2 == 1 ])
print(res)



Measured memory_bytes: 9024
#pragma GCC optimize ("O3")

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <algorithm>    // std::binary_search, std::sort
#include <vector>       // std::vector
using namespace std;

using QWORD = unsigned long long;
using SQWORD = long long;
using DWORD = unsigned int;
using SDWORD = int;
using WORD = unsigned short;
using SWORD = short;
using BYTE = unsigned char;
using SBYTE = char;
using DOUBLE = double;
using FLOAT = float;

#define MIN_SDWORD (-2147483648)
#define MAX_SDWORD (2147483647)
#define MIN_SBYTE (-128)
#define MAX_SBYTE (127)

#define MIN_SQWORD (0x8000000000000000)
#define MAX_SQWORD (0xFFFFFFFFFFFFFFFF)

#define MAX_QWORD  (0xFFFFFFFFFFFFFFFF)
#define MAX_DWORD  (0xFFFFFFFF)
#define MAX_WORD   (0xFFFF)
#define MAX_BYTE   (0xFF)


#define ArrayLength(a)  (sizeof(a) / sizeof(a[0]))

static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; }
static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; }
static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; }
static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; }
static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; }
static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; }

#define BYTE_BITS   (8)
#define WORD_BITS   (16)
#define DWORD_BITS  (32)
#define QWORD_BITS  (64)

using M_BOOL = bool;
#define M_TRUE (true)
#define M_FALSE (false)
#define DIVISOR (1000000007)

#define MAX_FACTORY (60)
static DWORD adwFactoryNum[MAX_FACTORY];
static DWORD adwFactoryCumMul[MAX_FACTORY];
static DWORD s_dwFactoryNum = 0;

static inline void inputString(char *pcStr)
{
    char *pcCur = pcStr;
    for (;;) {
        char c = getchar();
        if (('\n' == c) || (EOF == c)) {
            break;
        }
        *pcCur = c;
        pcCur++;
    }
    *pcCur = '\0';
}

static inline SDWORD inputSDWORD(void)
{
    SDWORD lNumber = 0;
    SDWORD lMultiplier = 1;
    M_BOOL bRead = M_FALSE;
    for (;;) {
        char c = getchar();
        if (!bRead) {
            if ('-' == c) {
                lMultiplier = -1;
            }
        }
        if (('0' <= c) && (c <= '9')) {
            lNumber *= 10;
            lNumber += (c - '0');
            bRead = M_TRUE;
        } else {
            if (bRead) {
                return lNumber * lMultiplier;
            }
        }
    }
}




int main()
{
    DWORD dwInput_N1, dwInput_N2, dwInput_N3, dwInput_N4;

    dwInput_N1 = inputSDWORD();
    dwInput_N2 = inputSDWORD();
    dwInput_N3 = inputSDWORD();
    dwInput_N4 = inputSDWORD();

    vector<DWORD> vValues;

    vValues.push_back(dwInput_N1);
    vValues.push_back(dwInput_N2);
    vValues.push_back(dwInput_N3);
    vValues.push_back(dwInput_N4);
    sort(vValues.begin(),vValues.end());

    if ((vValues[0] == 1) && (vValues[1] == 4) && (vValues[2] == 7) && (vValues[3] == 9)) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        long X = Long.parseLong(scanner.next());
        long Y = Long.parseLong(scanner.next());
        scanner.close();

        long num = X;

        int count = 0;
        do {
            count++;
            num = num * 2;
        } while (num <= Y);

        System.out.println(count);
    }

}


Measured memory_bytes: 22100
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

	ll  i, x, j, y, 	z, k, n;
	string s, t;
	cin >> s >> t;
	z = s.size();

	rep(i, 0, s.size(), 1) {
		if (i + t.size() > s.size())	break;
		k = 0;
		rep(j, 0, t.size(), 1) {
			k += (s[i + j] != t[j]);
		}
		z = min(z, k);
	}

	ce(z);
	debug(z);
}



Measured memory_bytes: 3640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int x,y;
  cin>>x>>y;
  string S="Yes";
  vector<int> a={0,1,3,1,2,1,2,1,1,2,1,2,1};
  if(a.at(x)!=a.at(y)) S="No";
  cout<<S;
return 0;}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    int N, M;
    cin>>N>>M;
    priority_queue<int> que;
    REP(i,0,N){
        int p;
        cin >> p;
        que.push(p);
    }
    REP(i, 0, M){
        int q = que.top(); que.pop();
        q /= 2;
        que.push(q);
    }
    long sum = 0;
    REP(i, 0, N){
        sum += que.top(); que.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 892
#include<stdio.h>
int main()
{
int a, b;
char op;
while(1){
scanf("%d %c %d", &a, &op, &b);
if(op=='+'){
printf("%d\n", a+b);
}
else if(op=='-'){
printf("%d\n", a-b);
}
else if(op=='*'){
printf("%d\n", a*b);
}
else if(op=='/'){
printf("%d\n", a/b);
}
else
if(op='?')
{ break;
}
else{
break;
}
}
return 0;
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    cout << c << endl;
  }
  if(a==c){
    cout << b << endl;
  }
  if(c==b){
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int i=0,j,c=0,saidai=0,m,n;
    string a;
    cin >> n;
    a=to_string(n);
    m=a.size();
    for(i=0;i<m;i++)
    {
        saidai+=a[i]-'0';
    }
    if(n%saidai==0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;

}


Measured memory_bytes: 3676
<?php
fscanf(STDIN, "%s", $b);

if($b == 'A'){
    echo $b = 'T';
} elseif ($b == 'G') {
    echo $b = 'C';
}elseif($b == 'T'){
    echo $b = 'A';
}else{
    echo $b = 'G';
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int h,w;
    cin>>h>>w;
    vector<vector<int>> c(h,vector<int>(w));
    rep(i,0,h){
        rep(j,0,w) cin>>c[i][j];
    }
    vector<vector<int>> dp(h+1,vector<int>(w+1));
    int maxwid=0;
    rep(i,0,h){
        rep(j,0,w){
            dp[i][j]=(c[i][j]+1)%2;
            maxwid|=dp[i][j];
        }
    }

    /*
    rep(i,0,h){
        rep(j,0,w)cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    cout<<maxwid<<endl;
    */

    rep(i,1,h){
        rep(j,1,w){
            if(c[i][j]){
                dp[i][j]=0;
            }else{
                dp[i][j]=min({dp[i-1][j-1],dp[i-1][j],dp[i][j-1]})+1;
                maxwid=max(maxwid,dp[i][j]);
            }
        }
    }
    cout<<maxwid*maxwid<<endl;
    
    /*
    rep(i,0,h){
        rep(j,0,w)cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    cout<<maxwid<<endl;
    */
    
    return 0;
}


Measured memory_bytes: 18212
#include<stdio.h>

int main()
{
	int n;
	int i;
	scanf("%d", &n);
	int a[n+1],b[n+1],c[n];
	int pre=-1;
	int manzoku=0;

	for(i=1;i<n+1;i++)
		scanf("%d",&a[i]);
	for(i=1;i<n+1;i++)
		scanf("%d",&b[i]);
	for(i=1;i<n;i++)
		scanf("%d",&c[i]);
	for(i=1;i<=n;i++){
		if(pre+1==a[i]){
			manzoku+=c[pre];
		}
		manzoku+=b[a[i]];
		pre=a[i];
	}
	printf("%d\n",manzoku);
	return 0;

}


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

using namespace std;

typedef long long ll;

const int MAX_N = 16384, MAX_M = 300;
const ll MOD = 998244353, MOD_G = 3;

ll sq(ll x) { return x * x % MOD; }
ll qpow(ll a, ll b) { return b ? sq(qpow(a, b / 2)) * (b & 1 ? a : 1) % MOD : 1; }
ll inv(ll x) { return qpow(x, MOD - 2); }

int N, M;
ll factorial[MAX_N], ifactorial[MAX_N], omega[MAX_N];

ll comb(int n, int m) { return factorial[n] * ifactorial[n - m] % MOD * ifactorial[m] % MOD; }

void NTT(ll A[], int n, int d = 1) {
    for (int i = 0, j = 0, k; i < n; i++) {
        if (i < j) swap(A[i], A[j]);
        for (k = n / 2; (j ^= k) < k; k /= 2);
    }

    for (int i = 1; i < n; i *= 2) {
        ll u = omega[(MAX_N + d * (MAX_N / (2 * i))) % MAX_N];
        for (int j = 0; j < n; j += 2 * i) {
            ll v = 1;
            for (int k = 0; k < i; k++) {
                ll a = A[j + k], b = A[j + k + i] * v % MOD;
                A[j + k] = (a + b) % MOD; A[j + k + i] = (a - b + MOD) % MOD;
                (v *= u) %= MOD;
            }
        }
    }

    if (d == -1) {
        ll inv_n = inv(n);
        for (int i = 0; i < n; i++) (A[i] *= inv_n) %= MOD;
    }
}

void init() {
    scanf("%d%d", &N, &M);
    factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) factorial[i] = factorial[i - 1] * i % MOD;
    ifactorial[MAX_N - 1] = inv(factorial[MAX_N - 1]);
    for (int i = MAX_N - 1; i; i--) ifactorial[i - 1] = ifactorial[i] * i % MOD;
    omega[0] = 1; omega[1] = qpow(MOD_G, (MOD - 1) / MAX_N);
    for (int i = 2; i < MAX_N; i++) omega[i] = omega[i - 1] * omega[1] % MOD;
}

ll F[MAX_M][MAX_N];

void solve() {
    F[0][0] = 1;
    for (int i = 0; i < M; i++) {
        static ll A[MAX_N], B[MAX_N];
        fill_n(A, MAX_N, 0);
        fill_n(B, MAX_N, 0);
        for (int j = 0; j <= N; j++) A[j] = F[i][j] * ifactorial[j] % MOD;
        for (int j = 1; j <= N; j++) B[j] = ifactorial[j + 2] % MOD;
        NTT(A, MAX_N);
        NTT(B, MAX_N);
        for (int j = 0; j < MAX_N; j++) (A[j] *= B[j]) %= MOD;
        NTT(A, MAX_N, -1);
        for (int j = 0; j <= N; j++) F[i + 1][j] = A[j] * factorial[j + 2] % MOD;
        for (int j = 0; j <= N; j++) {
            ll coe = j * (j + 1) / 2 + 1;
            (F[i + 1][j] += F[i][j] * coe) %= MOD;
        }
    }
    ll ans = 0;
    for (int i = 0; i <= N; i++)
        (ans += F[M][i] * comb(N, i)) %= MOD;
    printf("%lld\n", ans);
}

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

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    // 処理
    // 出力
    if (n < 1200) {
        cout << "ABC" << endl;

    } else if (n < 2800) {
        cout << "ARC" << endl;

    } else {
        cout << "AGC" << endl;
    }

    return 0;
}


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

const int limit = 2005;
char S[limit][limit];
int U[limit][limit], D[limit][limit], L[limit][limit], R[limit][limit];
int H, W;

int main(void) {
  cin >> H >> W;

  for (int k = 1; k <= H; k++) { scanf("%s", S[k] + 1); }

  for (int k = 1; k <= H; k++) {
    for (int l = 1; l <= W; l++) {
      if (S[k][l] == '.') {
        U[k][l] = U[k-1][l] + 1;
        R[k][l] = R[k][l-1] + 1;
      }
    }
  }

  for (int k = H; k >= 1; k--) {
    for (int l = W; l >= 1; l--) {
      if (S[k][l] == '.') {
        D[k][l] = D[k+1][l] + 1;
        L[k][l] = L[k][l+1] + 1;
      }
    }
  }

  int ans = 0;
  for (int k = 1; k <= H; k++) {
    for (int l = 1; l <= W; l++) {
      ans = max(ans, U[k][l] + D[k][l] + R[k][l] + L[k][l] - 3);
    }
  }
  cout << ans << endl;

}

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


using namespace std;

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

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

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

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

int main()
{
	int n,m;
	cin>>n>>m;
	vector<pair<ll,vector<ll>>> key;
	set<int> s;
	rep(i,m){
		ll a,b;
		cin>>a>>b;
		vector<ll> x(b);
		rep(j,b)cin>>x[j],s.insert(x[j]);
		key.push_back(pair<ll,vector<ll>>(a,x));
	}

	if(s.size()!=n){
		cout<<-1<<endl;
		return 0;
	}

	vector<vector<ll>> dp((1<<n),vector<ll>(m+1,1e15));
	dp[0][0] = 0;
	for (int i = 1; i <= m; i++){
		ll s = 0;
		for(auto x:key[i-1].second) s |= (1<<(x-1));
		rep(j,(1<<n)) dp[j][i] = dp[j][i-1];
		rep(j,(1<<n)){
			dp[s|j][i] = min(dp[s|j][i], dp[j][i-1]+key[i-1].first);
			// cout<<dp[s|j][i]<<endl;
		}
	}

	cout<<dp[(1<<n)-1][m]<<endl;

	return 0;
}

Measured memory_bytes: 32512
#include<cstdio>
#include<utility>
#include<queue>
using namespace std;int i,n,L,t,z[99999],s;int main(){typedef pair<int,int>y;priority_queue<y>q;y p;for(scanf("%d%d",&n,&L);i++<n;)scanf("%d",z+i);for(;--i;)z[i]>z[i-1]&z[i]>z[i+1]?q.push(y(z[i]-L,i)),z[i]=L:0;for(;!q.empty();n&&n!=L&n>z[s+2]?q.push(y(t-L+n,s+1)),z[s+1]=L:0)p=q.top(),q.pop(),t=p.first,z[s=p.second]=0,n=z[s-1],n&&n!=L&n>z[s-2]?q.push(y(t-L+n,s-1)),z[s-1]=L:0,n=z[s+1];printf("%d\n",-t);}

Measured memory_bytes: 1580
#include<iostream>
#include<string.h>
using namespace std;

int main(){
  string S;
  string T;
  
  cin>>S;
  cin>>T;
  
  int i=0,j=0;
  int ans=0,max=0;
  int kari1,kari2;
  
  for(i=0;S.size()>=T.size()+i;i++){
    ans=0;
    kari1=i;
    kari2=j;
    while(T.size()>=j+1){
      if(S[i]==T[j]){
       ans++;
        if(ans>max){
          max=ans;
        }
        
      }
      i++;
      j++;
      
    }
    i=kari1;
    j=kari2;

  }
  
  cout<<T.size()-max;
}

    
    
      
        
  
  



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c||b==c&&b!=a||c==a&&b!=c)
	cout<<"Yes";
	else
	cout<<"No";
}


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

int main()
{
	int n;
	cin >> n;
	int a[114514] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			cout << a[n-i-1] << endl;
		}
		else {
			cout << a[n-i-1] << " ";
		}
	}
}


Measured memory_bytes: 3552
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
c=0
for i in range(N):
    if A[i]<=B[i]:
        ans+=A[i]
        if A[i+1]>=B[i]-A[i]:
            ans+=B[i]-A[i]
            A[i+1]=A[i+1]-(B[i]-A[i])
        else:
            ans+=A[i+1]
            A[i+1]=0
    else:
        ans+=B[i]
print(ans)


Measured memory_bytes: 18476
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int n;
    while (cin >> n) {
        if (n == 0) {
            break;
        }
        vector<int> S(n);
        double avg = 0.0;
        for (auto &e : S) {
            cin >> e;
            avg += e;
        }
        avg /= n;
        double ans = 0.0;
        for (auto &e : S) {
            ans += (e - avg) * (e - avg);
        }
        cout << sqrt(ans / n) << "\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3324
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  int res = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    while (a >= 2 && a % 2 == 0) {
      a >>= 1;
      ++res;
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 3232
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
cout<<n*n*n;
}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    
    string s;
    
    int n;
    
    cin >> s;
   
  
    
    n = s.size();
    
    int l= n-2;
    
    cout <<s[0]<<l<<s[l+1]<<endl;
    
    
    
  
  return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int gra[10][10];
int visited[10];
int N,M,ans;

int all_visited(){
	int a=1;
	for(int i=1;i<=N;i++)a*=visited[i];
	if(a>0)return 1;
	return 0;
}

void DFS(int v){
	if(all_visited()==1){
		ans++;
		return;
	}
	for(int i=1;i<=N;i++){
		if(gra[v][i]==1 && visited[i]==0){
			visited[i]=1;
			DFS(i);
			visited[i]=0;
		}
	}
	return;
}

int main(){
	scanf("%d%d",&N,&M);
	
	for(int i=0;i<M;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		gra[a][b]=gra[b][a]=1;
	}
	
	visited[1]=1;
	DFS(1);
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e5 + 5;
int mem[N];
vector< vector<int> > adj(N);
int dfs(int node){
    int &ret = mem[node];
    if(~ret)
        return ret;
    ret = 0;
    for(int child: adj[node]){
        ret = max(ret, dfs(child) + 1);
    }
    return ret;
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    memset(mem, -1, sizeof(mem));
    int n, m;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    int res = 0;
    for(int i=1; i<=n; i++){
        res = max(res, dfs(i));
    }
    cout<<res<<'\n';
}

Measured memory_bytes: 11028
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a;
  int miVal=1000,miIndex=0;
  for(int i=0;i<n;i++){
      int x;
      cin>>x;
      a.push_back(x);
      if(a[i]<miVal){
        miVal=a[i];
        miIndex=i;
      }
  }
  int ball=miIndex;
  int times=k;
  int old=-1;
 
  vector<int> ans;
  while(times>=0){
      int mi=1000,index=0;
      for(int i=0;i<n;i++){
        if(i==old) continue;
        if(a[i]==0){
          cout<<-1<<endl;
          return 0;
        }
        if(i==ball) continue;
        ans.push_back(i);
        a[i]--;
      }
 
      for(int i=0;i<n;i++){
        if(i==ball) continue;
        if(mi>a[i]){
          mi=a[i];
          index=i;
        }
      }
 
      ans.push_back(ball);
      a[ball]--;
      old=ball;
      ball=index;
      times--;
  }
 
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]+1<<" ";
  }
  cout<<endl;
 
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(c) for c in input().split()]

A_plus, A_minus = [], []
for a in A:
    if a>0: A_plus.append(a)
    else: A_minus.append(a)

if len(A_minus)%2==0:
    print(sum(A_plus) - sum(A_minus))
elif len(A_plus)==0:
    print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)    
else:
    if min(A_plus) > -max(A_minus):
        print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)
    else:
        print(sum(A_plus) - sum(A_minus) - min(A_plus)*2)
        


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

int main(void){
  int a,b;
  int taps = 1;
  int n = 0;
  
  cin >> a >> b;
  while (taps<b){
    n++;
    taps += (a-1);
  }
  cout << n << endl;
  return 0;
}
  

Measured memory_bytes: 256
import sys
import itertools

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]


    accu = list(itertools.accumulate(A))

    ans1 = 0
    ruiseki = 0
    for i, x in enumerate(accu):
        if i % 2 == 0:
            if ruiseki + x <= 0:
                ans1 += 1 + abs(ruiseki + x)
                ruiseki += 1 + abs(ruiseki + x)
        else:
            if ruiseki + x >= 0:
                ans1 += 1 + abs(ruiseki + x)
                ruiseki += -1 - abs(ruiseki + x)

    ans2 = 0
    ruiseki = 0
    for i, x in enumerate(accu):
        if i % 2 != 0:
            if ruiseki + x <= 0:
                ans2 += 1 + abs(ruiseki + x)
                ruiseki += 1 + abs(ruiseki + x)
        else:
            if ruiseki + x >= 0:
                ans2 += 1 + abs(ruiseki + x)
                ruiseki += -1 - abs(ruiseki + x)

    print(min(ans1, ans2))

if __name__ == '__main__':
    main()


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

#define pb push_back
#define mp make_pair
#define up upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define ll long long
#define vi vector < ll > 
#define pi pair < ll , ll > 
#define ld long double
#define iPair pair< ll , ll >

#define lp(n,i) for(ll i=0;i<n;i++)
#define rlp(n) for(ll i=n-1;i>=0;i--)
//#define e 1000000009
//#define e  998244353
#define inf 9999999999999999
#define pri1 1000000007
#define pri2 1000001001
#define PI 3.14159265
 /*
ll pw(ll a, ll b)
{
    ll t=1;
    
    if(b==0)return t;
    if(b%2)
    {
        t=t*a;
    }
   t%=e;
    ll x=pw(a,b/2);
    x=x*x;
    x%=e;
    t*=x;
    t%=e;
    return t;
}/*
vector < ll > pr;
ll vis[10000005]={0};
void seive ( ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(vis[i]==0)
        {
            
            for(ll j=i*i;j<=n;j+=i)vis[j]=1;
        }
    } 
    
    for(ll i=2;i<=n;i++)
    {
        if(vis[i]==0)pr.pb(i);
    }
}
 
#define N 100005
ll z[N];
vector < ll > v;
void getz(string s)
{
    ll n=s.length();
    ll l=0,r=0;
    for(ll i=1;i<n;i++)
    {
        if(i<=r)
        {
            z[i]=min(r-i+1,z[i-l]);
        }
        
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]])z[i]++;
        
        if((i+z[i]-1)>r)
        {
            l=i;
            r=i+z[i]-1;
        }
    }
    
   for(ll i=0;i<n;i++)
   {
       v.pb(z[i]);
   }
  
    sort(v.begin(),v.end());
    
}
*/
 

 
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
 
   
 ll ti=1;
//cin>>ti;
 
 for (ll io=0;io<ti;io++)
 {
     ll a,b,h,m;
     cin>>a>>b>>h>>m;
     
    double x=h*30.0;
    if(m)x+=(30.0/60)*m;
    double y=6.0*m;
    //cout<<x<<" "<<y<<endl;
     x=x-y;
     x=x*3.1415926535;
     x=x/180;
     
    double ans=a*a+b*b-2*a*b*cos(x);
    //cout<<ans<<endl;
    ans=sqrt(ans);
    cout<<fixed<<setprecision(10)<<ans<<endl;
 }
 return 0;	
}

Measured memory_bytes: 4176
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int dp[2][3030][2];
int ma[3030][2];
int main(){
	int n,t,s,a[3030],b[3030];
	cin>>n>>t>>s;
	int r=t-s;
	REP(i,n)cin>>a[i+1]>>b[i+1];
	memset(dp,-1,sizeof(dp));
	dp[0][0][0]=0;
	REP(i,n){
		REP(j,t+1){
			if(dp[i&1][j][0]!=-1){
				dp[(i+1)&1][j][0]=max(dp[(i+1)&1][j][0],dp[i&1][j][0]);
				if(j+b[i+1]<=s)dp[(i+1)&1][j+b[i+1]][0]=max(dp[(i+1)&1][j+b[i+1]][0],dp[i&1][j][0]+a[i+1]);
			}
		}
		REP(j,s+1)ma[i+1][0]=max(ma[i+1][0],dp[(i+1)&1][j][0]);
	}
	dp[(n+1)&1][0][1]=0;
	int ans=0;
	for(int i=n+1;i>1;i--){
		REP(j,t+1){
			if(dp[i&1][j][1]!=-1){
				dp[(i-1)&1][j][1]=max(dp[(i-1)&1][j][1],dp[i&1][j][1]);
				if(j+b[i-1]<=r)dp[(i-1)&1][j+b[i-1]][1]=max(dp[(i-1)&1][j+b[i-1]][1],dp[i&1][j][1]+a[i-1]);
			}
		}
		REP(j,r+1)ma[i-1][1]=max(ma[i-1][1],dp[(i-1)&1][j][1]);
	}
	REP(i,n+1){
		ans=max(ans,ma[i][0]+ma[i+1][1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1264
import sys
input = sys.stdin.readline
def solve():
  n,m  =(int(i) for i in input().split())
  if n == 1 and m == 1:
    print(1)
  elif n == 1:
    print(m-2)
  elif m== 1:
    print(n-2)
  else:
    print((n-2)*(m-2))
solve()
  

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
   int n,k,t;
   cin>>n>>k>>t;
   cout<<fixed<<setprecision(0)<<ceil((double) n/k)*t;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3796
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#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 pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define Vl(v,n) vector<ll> v(n);
#define Read_vll(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(ac,n) REP(i,0,n) ac[i] = v[i] + ( i == 0 ? 0 : ac[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(n)
    Read_vll(a,n)
    SORT(a)
    sumV(a,n)


    ll ma = 0;
    for( ll i = n - 1; i >= 0; i-- ){
      if( 2 * ac[i-1] < a[i] ){
        ma = fmax( ma, i );
      }
    }
    cout << n - ma << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int m;
	cin >> m;
	int64 res = -1;
	int64 sum = 0;
	for (int i = 0; i < m; ++i) {
	    int64 d, c;
		cin >> d >> c;
		res += c;
		sum += d * c;
	}
	res += (sum - 1) / 9;
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define gcd __gcd
using namespace std;

int main() {
  string s;
  cin>>s;
  ll ans=0;
  for(ll i=0;i<s.size();i++) {
    if(s.at(i)=='2') {
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n, -q + k);
    for (int i = 0; i < q; ++i)
    {
        int x;
        cin >> x;
        a[x - 1]++;
    }
    for (int i = 0; i < n; ++i)
    {
        if (a[i] <= 0)
            cout << "No\n";
        else
            cout << "Yes\n";
    }

    return 0;
}

Measured memory_bytes: 1024
#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 <unordered_map>
#include <unordered_set>
#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>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;


int main(){
  int N;
  int ans=0;
  cin>>N;
  //vector<int> A(N);
  unordered_map<string,int> m;
  for(int i=0; i<N; i++){
    string a;cin>>a;
  if(!m.count(a)){m[a]=1;ans++;}
  }
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
 }

Measured memory_bytes: 17788
#include <stdio.h>
#include <string.h>

int main(void)
{
  char buff[100];
  fgets(buff, sizeof buff, stdin);

  long a, b;
  a = atol(strtok(buff, " "));
  b = atol(strtok(NULL, " "));
  
  long ax =1, bx = 1;
  while (a * ax != b * bx) {
    if (a * ax < b * bx) {
      ax++;
    } else {
      bx++;
  	}
  }
  printf("%ld", a * ax);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//cout << fixed << setprecision();
//priority_queue<ll, vector<ll>, greater<ll>> q;
signed main(){
	ll hp,n; cin>>hp>>n;
	vl a(n),b(n);
	rep(i,0,n)cin>>a[i]>>b[i];
	vvl dp(n+10,vl(100000,MOD));
	dp[0][0]=0;
	rep(i,0,n){
		rep(j,0,100000){
			ll k=dp[i][j];
			if(j-a[i]>=0)chmin(k,dp[i+1][j-a[i]]+b[i]);
			dp[i+1][j]=k;
		}
	}
	ll ans=MOD;
	rep(i,hp,100000)chmin(ans,dp[n][i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 795992
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int cost0 =0;
        int costN =0;
        int [] A = new int[M];
        for (int i =0;i<M;i++){
            A[i] = sc.nextInt();
        }
        for (int i =X;i>0;i--){
            for (int j =0;j< M;j++){
                if(A[j] == i){
                    cost0++;
                }
            }
        }
        for (int i =X;i<N;i++){
            for (int j =0;j< M;j++){
                if(A[j] == i){
                    costN++;
                }
            }
        }
        System.out.println(Math.min(cost0,costN));
    }
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

int solve(int N,int M,vi& a,vi& b) {
    int adj[8][8];
    mset(adj, 0);

    rep(i,M){
        adj[a[i]-1][b[i]-1] =
        adj[b[i]-1][a[i]-1] = 1;
    }
    int cnt = 0;
    vi iota(N);
    rep(i,N) iota[i] = i;
    do{
        bool ok = true;
        rep(i,N-1){
            if (!adj[iota[i]][iota[i+1]]) { ok = false; break; }
        }
        if (ok){
            // cerr << iota << endl;
            ++cnt;
        }
    }while(next_permutation(iota.begin()+1, iota.end()));
    return cnt;
}

int main() {
    int N,M; cin>>N>>M;
    vi a(M),b(M);
    rep(i,M) cin>>a[i]>>b[i];
    cout << solve(N,M,a,b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans,N;
map<int,int>mp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        mp[a]++;
    }
    for(auto p:mp){
        if(p.first>p.second){
            ans+=p.second;
        }
        else{
            ans+=p.second-p.first;
        }
    }
    cout<<ans<<'\n';;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,d,i;
 cin>>n;
 string s;
 cin>>s;
 int cunt=0,l=0,r=n-1;
 for(i=0;i<n-1;i++)
 {
     if(s[i]=='W')
     {
         while(s[r]=='W')
         {
             r--;
         }
         if(r>i)
         {
             swap(s[i],s[r]);
             cunt++;
         }
         else break;
     }
 }
 cout<<cunt<<endl;
 return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
 using namespace std;
 int N, A[3][3], b[10];
 bool appear[3][3];
 int main() {
 for(int i = 0; i < 3; i++) {
 for(int j = 0; j < 3; j++) cin >> A[i][j];
 }
 cin >> N;
 for(int i = 0; i < N; i++) cin >> b[i];
 for(int i = 0; i < N; i++) {
 for(int j = 0; j < N; j++) {
 appear[i][j] = false;
 for(int k = 0; k < N; k++) {
 if(A[i][j] == b[k]) appear[i][j] = true;
 }
 }
 }
 string ANS = "No";
 for(int i = 0; i < 3; i++) {
 if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
 }
 for(int i = 0; i < 3; i++) {
 if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
 }
 if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
 if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
 cout << ANS << endl;
 return 0;
 }


Measured memory_bytes: 3628
#include <set>
#include <string>
#include <iostream>
using namespace std;
string s;
set<int> expr(int l, int r) {
	int cnt = 0;
	for (int i = l; i < r; i++) {
		if (s[i] < 48 || 57 < s[i]) cnt++;
	}
	if (cnt == 0) return set<int>({ stoi(s.substr(l, r - l)) });
	set<int> ret;
	int depth = 0, cnt2 = 0;
	for (int i = l; i < r; i++) {
		if (s[i] == '(') depth++;
		if (s[i] == ')') depth--;
		if (depth == 0) cnt2++;
		if (depth == 0 && (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/')) {
			set<int> r1 = expr(l, i);
			set<int> r2 = expr(i + 1, r);
			if (s[i] == '+') {
				for (int j : r1) {
					for (int k : r2) {
						ret.insert(j + k);
					}
				}
			}
			if (s[i] == '-') {
				for (int j : r1) {
					for (int k : r2) {
						ret.insert(j - k);
					}
				}
			}
			if (s[i] == '*') {
				for (int j : r1) {
					for (int k : r2) {
						ret.insert(j * k);
					}
				}
			}
			if (s[i] == '/') {
				for (int j : r1) {
					for (int k : r2) {
						if (k == 0) continue;
						if (j > 0) ret.insert(j / k);
						else ret.insert(-((-j) / k));
					}
				}
			}
		}
	}
	if (cnt2 == 1) return expr(l + 1, r - 1);
	return ret;
}
int main() {
	while (cin >> s, s != "#") {
		set<int> ret = expr(0, s.size());
		cout << ret.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      Long N = sc.nextLong();
      Long K = sc.nextLong();
      
      // 操作
      Long quot = N / K;
      Long candidate1 = abs(N - K * quot);
      Long candidate2 = abs(N - K * (quot+1));
      Long min;
      if(candidate1 < candidate2){
        min = candidate1;
      }else{
        min = candidate2;
      }
      
      // 出力
      System.out.println(min);
    }
    
    // 絶対値を求める関数
    public static Long abs(Long num){
      if(num < 0){
        return num * (-1);
      }else{
        return num;
      }
    }

}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int N, T; cin >> N >> T;
	int c[105], t[105];
	int ans = 0;
	for(int i=0;i<N;i++){
		cin >> c[i] >> t[i];
		ans = max(c[i], ans);
	}
	ans++;
	int cost = ans;
	for(int i=0;i<N;i++){
		if(t[i]<=T){
			ans = min(ans, c[i]);
		}
	}
	if(ans!=cost){
		cout << ans << endl;
		return 0;
	}else{
		cout << "TLE" << endl;
		return 0;
	}
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define print(x) cout << x << endl

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; }

ll MOD = 1000000007;


int main()
{
    ll n, m;
    cin >> n >> m;
    if (n == m)
        print("Yes");
    else
        print("No");
    return 0;
}


Measured memory_bytes: 256