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

typedef int64_t i64;
typedef uint64_t ui64;

class graph{
public:
    struct adj{
        int index;
        int start;
        int to;
        i64 cost;
    };
    int nd;
    int eg;
    vector<adj> *node;
    vector<adj> edge;
    graph(int n,int m){
        nd=n;
        eg=m;
        node=new vector<adj>[nd]{};
        edge={};
    }
    void add_dir(int i,int s,int t,i64 c){
        node[s].push_back({i,s,t,c});
        edge.push_back({i,s,t,c});
    }
    void add_undir(int i,int s,int t,i64 c){
        node[s].push_back({i,s,t,c});
        node[t].push_back({i,t,s,c});
        edge.push_back({i,s,t,c});
    }
    void refr(void){
        for(int i=0;i<nd;i++) vector<adj>().swap(node[i]);
        delete[] node;
        vector<adj>().swap(edge);
    }
    bool IsLink(void);
    void DFS(int r,i64 *&p,bool *&vst);
    bool IsPlus(void);
    void BellmanFord(int s,i64 *&d);
    void Dijkstra(int s,i64 *&d);
    void BFS(int s,i64 *&d);
    void WarshallFloyd_dir(i64 **&d);
    void WarshallFloyd_undir(i64 **&d);
    i64 WMST_dir(int r);
    i64 WMST_undir(void);
    void Edmonds(int r,vector<adj> &p);
    void Kruscal(vector<adj> &p);
    void Prim(vector<adj> &p);
    void Artic(vector<int> &p);
    void Artic_sub(int r,int &k,int par,vector<int> &p,int *&ord,int *&low,bool *&vst);
    void Bridge(vector<adj> &p);
    void Bridge_sub(int r,int &k,int par,vector<adj> &p,int *&ord,int *&low,bool *&vst);
    void SCC(int *&c);
    void SCC_sub1(int r,vector<int> &vs,bool *&vst);
    void SCC_sub2(int r,int k,int *&c,bool *&vst,graph &rg);
    bool IsDAG(void);
    bool IsDAG_sub(int r,int &k,int *&l,int *&vst);
    void TopolSort(int *&l);
    void TopolSort_sub(int r,int &k,int *&l,bool *&vst);
    void Cumul(int s,i64 *&d);
};

void graph::TopolSort(int *&l){
    bool *vst=new bool[nd]{};
    int k=0;
    for(int i=0;i<nd;i++){
        if(!vst[i]) TopolSort_sub(i,k,l,vst);
    }
    stack<int> stk;
    for(int i=0;i<nd;i++) stk.push(l[i]);
    for(int i=0;i<nd;i++){
        l[i]=stk.top();
        stk.pop();
    }
    delete[] vst;
}

void graph::TopolSort_sub(int r,int &k,int *&l,bool *&vst){
    if(!vst[r]){
        vst[r]=1;
        for(const auto &i:node[r]){
            if(!vst[i.to]) TopolSort_sub(i.to,k,l,vst);
        }
        l[k]=r;
        k++;
    }
}

int main(void){
    int v,e;
    scanf("%i%i",&v,&e);
    graph g(v,e);
    int s,t;
    for(int i=0;i<e;i++){
        scanf("%i%i",&s,&t);
        g.add_dir(i,s,t,1);
    }
    int *l=new int[v];
    g.TopolSort(l);
    for(int i=0;i<v;i++){
        printf("%i\n",l[i]);
    }
    return 0;
}



Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  
  ll n;
  cin >>n;
  if(n%2 == 1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  for(int i=1;pow(5,i)<=n;i++){
    ans += n/(long long)(pow(5.0f,i)*2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


def main():
    N, M =two_int()

    key_list=[]
    treasures=[]
    check={}

    for i in range(M):
        mon,_ =two_int()
        temp = map(lambda x: 1<<(x-1), many_int())
        sums = sum(temp)
        
        if sums in check:
            if check[sums] > mon:
                check[sums]=mon
        else:
            check[sums]=mon
            
    for k,v in check.items():
        key_list.append(v)
        treasures.append(k)

    max_index=2**N
    INF=10**15

    dp=[INF for i in range(max_index)]
    dp[0]=0
    M=len(key_list)

    for i in range(max_index-1):
        for j in range(M):
            new_i = int(bin(treasures[j] | i),2)
            cost = dp[i] + key_list[j]
            dp[new_i] = min(dp[new_i], cost) 
        
    goal_index=max_index-1
    if dp[goal_index]!=INF:
        print(dp[goal_index])
    else:
        print(-1)

main()

Measured memory_bytes: 42732
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,X,T,ans=0;
  cin>>N>>X>>T;
  ans=(N+X-1)/X*T;
  
  co(ans);
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll a[n];
    ll now = 1e18;
    ll ans = 1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
        now /= a[i];
        ans *= a[i];
    }
    if(now == 0) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 4436
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())

    K = 0
    for i in range(450):
        if i * (i-1) // 2 == N:
            K = i
            break

    if K == 0:
        print("No")
        exit()
    
    S = [[0] * (K-1) for _ in range(K-1)]

    a = 1
    for i in range(K-1):
        for j in range(i+1):
            S[i][j] = a
            S[j][i] = a
            a += 1

    tri = [S[i][i] for i in range(K-1)]

    print("Yes")
    print(K)

    for s in S:
        print(K - 1, *s)
    
    print(K - 1, *tri)

    
if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

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

    string S;
    cin >> S;

    cout << (S[2] == S[3] and S[4] == S[5] ? "Yes": "No") << '\n';

    return 0;
}


Measured memory_bytes: 3604
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (h, _) = scan!(usize, usize);
    let image = scan!(;;h);
    for line in image.iter() {
        println!("{}", line);
        println!("{}", line)
    }
}


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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

long long binarySearch(long long ok, long long ng, std::function<bool(long long)> check) {
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    return ok;
}

int N, K;
int A[220000], F[220000];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> A[i]; }
    sort(A, A + N);
    rep(i, N) { cin >> F[i]; }
    sort(F, F + N), reverse(F, F + N);
    cout << binarySearch((int) 1e13, -1, [&](int x) {
        int sum = 0;
        rep(i, N) {
            sum += max(0LL, A[i] - x / F[i]);
        }
        return sum <= K;
    }) << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 string a;
  cin>>a;
  if(a=="RRR"){
    cout<<3;
  }
  else if(a=="RRS"||a=="SRR"){
    cout<<2;
  }
  else if(a=="SSS"){
    cout<<0;
  }
  else{
  cout<<1;
  }
}   


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include<ios>
using namespace std;
int main(){
     ios::sync_with_stdio(false);
     const int INF = INT32_MAX>>3;
     int N, h[100001], dp[100001];
     cin >> N;
     for (int i = 0; i < N; i++) {
         cin >> h[i];
         dp[i] = INF;
     }
    dp[0] = 0;
    dp[1] = dp[0] + abs(h[1] - h[0]);
    for(int i = 2; i < N; ++i){
        dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i]- h[i-1]));
    }
    cout << dp[N-1] << "\n";
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Text;

class Program{
    static void Main(string[] args){
        var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = arr[0];
        var a = arr[1];
        var b = arr[2];
        var c = 0;
        var d = 0;
        var s = Console.ReadLine();
        var stringBuilder = new StringBuilder();
        for (int i = 0; i < n; i++){
            if (s[i] == 'c'){
                stringBuilder.Append("No").AppendLine();
                continue;}
            if(c < a + b){
                if (s[i] == 'a'){
                    stringBuilder.Append("Yes").AppendLine();
                    c++;
                    continue;}

                if (d < b){
                    stringBuilder.Append("Yes").AppendLine();
                    c++;
                    d++;
                    continue;}}
            stringBuilder.Append("No").AppendLine();}
        var answer = stringBuilder.ToString();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 29924
package main


import (
    "fmt"
)

func main() {
    var A,B int
    var op string

    fmt.Scan(&A,&op,&B)

    if op == "+" {
      fmt.Println(A+B)

    } else if op == "-" {
      fmt.Println(A-B)

    } else {
      fmt.Println("error")
    }

}

Measured memory_bytes: 512
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "happy,newyear,enjoy" => "happy newyear enjoy",
    "haiku,atcoder,tasks" => "haiku atcoder tasks",
    "abcde,fghihgf,edcba" => "abcde fghihgf edcba",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: String,
    }

    s.replace(",", " ")
}

Measured memory_bytes: 4352
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int ans  =a%b;
			System.out.println(ans == 0 ? b : ans);
		}
	}
}

Measured memory_bytes: 20348
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  }
  else if (s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int x;
  while (scanf("%d", &x) != EOF)
  {
    printf("%s\n", x >= 30 ? "Yes" : "No");
  }
  return 0;
}

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

int main(){
    int k,s;
    cin >> k >> s;
    int count=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-i-j<=k&&s-i-j>=0)
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

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

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

    for (int x:a) {
        if ((x%2==0) && (x%3!=0 && x%5!=0)) {
            cout << "DENIED\n";
            return 0;
        }
    }

    cout << "APPROVED\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
int main(){
	std::string str;
	int rings,count=0;
	std::cin >> str >> rings;
	std::vector<bool> v (rings,false);
	std::vector<std::string> ring(rings);
	for (int i = 0; i < rings; i++) {
		std::cin >> ring[i];
		ring[i] += ring[i];
		for (int j = 0; j < 10; j++) {
			if (ring[i].substr(j, str.size()) == str) {
				v[i] = true;
			}
		}
		if (v[i] == true) {
			count++;
		}
	}
	std::cout << count << std::endl;
	
	return 0;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ans = 0, sum = 0;
    rep1(i, n-1) {
        sum = ((ll)sum + a[i-1]) % mod;
        ans = (ans + (ll)a[i] * sum) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	unordered_map <string,ll> mapp;
	for (int z=1;z<=n;z++){
		string a = to_string(z);
		string b;
		b += a[0];
		b += a[a.size()-1];
		mapp[b]++;
	}
	ll ans = 0;
	for (int z=1;z<=n;z++){
		string a = to_string(z);
		string b;
		b += a[a.size()-1];
		b += a[0];
		ans += mapp[b];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import re
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

K,X = MULT_INT_LIST()
ans = []
kuro_min = X-K+1
kuro_max = X+K-1
for i in range(kuro_min,kuro_max+1):
    ans.append(i)
ans = str(ans)
ans = ans.replace(",", "")
ans = ans.strip('[]') 
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2;
}

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

int main() {
	int a,b; cin>>a>>b;
	if(a==2||b==2)cout<<"No"<<endl;
	else{
		int count=0;
		if(a==4||a==6||a==9||a==11)count++;
		if(b==4||b==6||b==9||b==11)count++;
		cout<<(count%2==0?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

g = int(readline())

def pow(n,p): #繰り返し二乗法(nのp乗)
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2
            p //= 2
        else:
            res = res * n
            p -= 1
    return res

for i in range(200):
    for j in range(200):
        k = pow(i,5)
        l = pow(j,5)
        if k-l == g:
            print(i,j)
            exit()
        elif k+l == g:
            print(i,-j)
            exit()

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;

int main()
{
    int n;
    while(cin >>n,n)
    {
        //schedule
        int s[50][31]={0};

        rep(i,n)
        {
            int f;
            cin >>f;
            rep(j,f)
            {
                int d;
                cin >>d;
                s[i][d]=1;
            }
        }

        int ans=-1;
        vector<vi> v(n,vi(n,0));

        //i-th day
        for(int i=1; i<=30; ++i)
        {
            rep(j,n)rep(k,n)
            {
                if(s[j][i] && s[k][i])
                {
                    v[j][j]=1;
                    v[k][k]=1;
                    v[j][k]=1;
                    v[k][j]=1;

                    rep(x,n)
                    {
                        v[j][x]|=v[k][x];
                        v[k][x]|=v[j][x];
                    }
                }
            }

            rep(j,n)
            {
                int ct=0;
                rep(k,n) ct+=v[j][k];
                if(ct==n)
                {
                    ans=i;
                    break;
                }
            }

            if(ans>0) break;
        }

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

Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N, A, MIN;

int main(){
	cin >> N;
	MIN = llmax;
	for (int i = 0; i < 5; ++i) {
		cin >> A;
		MIN = min(MIN, A);
	}
	cout << (N - 1) / MIN + 5 << endl;
	return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 100000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

  int A,B;
  cin>>A>>B;
  //. A
  //# B
  
  //cout<<A<<" "<<B<<endl;;
  int h=100,w=100;
  vector<vector<char> >map(100,vector<char>(100));
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(i%2)map[j][i]='.';
      else map[j][i]='#';
    }
  }
  for(int i=0;i<100;i++){
    map[0][i]='#';
  }
  for(int i=0;i<100;i++){
    map[99][i]='.';
  }

  vector<pii>ta,tb,a,b;
  pii af,bf;
  for(int i=0;i<49;i++){
    ta.push_back({99,2*i+1});
  }
  for(int i=1;i<50;i++){
    tb.push_back({0,2*i});
  }
  for(int i=0;i<49;i++){
    for(int j=0;j<50;j++){
      a.push_back({2*i+1,2*j});
    }
  }
  for(int i=1;i<50;i++){
    for(int j=0;j<50;j++){
      b.push_back({2*i,2*j+1});
    }
  }
  reverse(rng(a));

  A--;
  B--;
  for(int i=0;i<a.size();i++){
    if(B>0){
      map[a[i].first][a[i].second]='.';
      B--;
    }
    else break;
  }
  for(int i=0;i<a.size();i++){
    if(A>0){
      map[b[i].first][b[i].second]='#';
      A--;
    }
    else break;
  }
  for(int i=0;i<49;i++){
    if(A>=1&&B>=2){
      map[tb[i].first][tb[i].second]='.';
      A--;
      B-=2;
    }
    else break;
  }
  for(int i=0;i<49;i++){
    if(B>=1&&A>=2){
      map[ta[i].first][ta[i].second]='#';
      B--;
      A-=2;
    }
    else break;
  }
  //cout<<A<<" "<<B<<endl;

  cout<<100<<" "<<100<<endl;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      cout<<map[j][i];
    }
    cout<<endl;
  }
  return 0;
}


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

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

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

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

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int N, M1, M2;
	cin >> N >> M1 >> M2;
	union_find uf1(N), uf2(N);
	while (M1--) {
		int u, v; scanf("%d%d", &u, &v);
		u--; v--;
		uf1.unite(u, v);
	}
	while (M2--) {
		int u, v; scanf("%d%d", &u, &v);
		u--; v--;
		uf2.unite(u, v);
	}
	map<i_i, int> mp;
	rep(u, N) {
		int x = uf1.find(u), y = uf2.find(u);
		mp[i_i(x, y)]++;
	}
	rep(u, N) {
		int x = uf1.find(u), y = uf2.find(u);
		printf("%d ", mp[i_i(x, y)]);
	}
	cout << endl;
}


Measured memory_bytes: 13568
# editorial準拠
def main():
    from collections import deque
    K = int(input())

    q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
    cnt = 0
    while q:
        x = q.popleft()
        cnt += 1
        if cnt == K:
            print(x)
            return

        y = x % 10
        z = 10*x + y
        if y != 0:
            q.append(z-1)
        q.append(z)
        if y != 9:
            q.append(z+1)


if __name__ == '__main__':
    main()


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

int main(){
  int64_t a,b,c,d,e;
  cin >> a >> b >> c >> d;
  a = a-1;
  int64_t sum =  (b/c-a/c) + (b/d-a/d);
  int64_t i=min(c,d),j= max(c,d) % min(c,d);

  while(j!=0){
    e = i;
    i = j;
    j = (int64_t)e%i;
  }
  e = c*d/i;
  sum -= (b/e-a/e);
  sum = (b-a)-sum;
  cout << sum;
}
 
  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int W, B;
    cin >> W >> B; //
    vector<vector<char>> C(96, vector<char>(96, '.'));
    rep(i, 48, 96){
        rep(j, 96){
            C[i][j] = '#';
        }
    }
    W--;
    B--;
    int h = 1, w = 1;
    while(B--) {
        C[h][w] = '#';
        w += 2;
        if(w >= 96){
            h += 2;
            w = 1;
        }
    }
    h = 49, w = 1;
    while(W--) {
        C[h][w] = '.';
        w += 2;
        if(w >= 96){
            h += 2;
            w = 1;
        }
    }
    cout << 96 << " " << 96 << endl;
    rep(i, 96){
        rep(j, 96){
            cout << C[i][j];
        }
        cout << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
//#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, B;
	cin >> A >> B;
	if (A >= 13) {
		cout << B << endl;
	}
	else if (A >= 6 && A < 13) {
		cout << B / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	rep(i, N)a[i]--;

	int ans = 0;
	rep(i, N)if (a[a[i]] == i)ans++;
	cout << ans / 2 << endl;
}

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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    ll a,b,c,x,y = 0;
    cin >> a >> b >> c >> x >> y;

    ll MIN = 1001001001;
    for(ll i = 0;i <= max(x,y);i++){
        ll aCnt,bCnt,abCnt = 0;
        if(x >= y){
            aCnt = i;
            if(x >= i){
                abCnt = (x - i) * 2;
            }
            if(y >= abCnt / 2){
                bCnt = y - abCnt / 2;
            }
            //cout << aCnt << " " << bCnt << " " << abCnt << endl;
            MIN = min(MIN,aCnt * a + bCnt * b + abCnt * c);
        }else{
            bCnt = i;
            if(y >= i){
                abCnt = (y - i) * 2;
            }
            if(x >= abCnt / 2){
                aCnt = x - abCnt / 2;
            }
            //cout << aCnt << " " << bCnt << " " << abCnt << endl;
            MIN = min(MIN,aCnt * a + bCnt * b + abCnt * c);
        }
        
    }
    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e4+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=998244353;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
ll a[maxn],dp[maxn];
int main()
{
	io();
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i]; 
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		dp[0]+=1;
		for(int j=k;j>=a[i];j--)
			dp[j]=(dp[j]+dp[j-a[i]])%mod;
		ans=(ans+dp[k])%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
inline int read()
{
    int x=0;bool f=false;char ch=getchar();
    while(ch<48 | ch>57) f|=(ch=='-'),ch=getchar();
    while(ch>47 && ch<58) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
int main()
{
	register int a,b,c,i;
	a=read(),b=read(),c=read();
	for(i=1; i<=b; ++i)
		if(a*i%b==c) return printf("YES\n"),0;	
	return printf("NO\n"),0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;



long long int n,m,k,a[200005],b,c,d,count=0,res=0,tmp;
int main() {
    int count=0;
    string str;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=i){
            count++;
        }
    }
    if(count==0||count==2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
} 


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>

int main()
{
	std::vector<int> x;
	int a, b;
	while (scanf("%d %d", &a, &b) != EOF)
		x.push_back(a+b);

	for (int i = 0; i < x.size(); ++i)
		std::cout << static_cast<int>(log10(x[i])) + 1 << std::endl;
	return 0;
}

Measured memory_bytes: 1272
let bin_search x (a : int array) =
  let rec doit l r =
    if l >= r then false
    else begin
      let m = (l + r) / 2 in
      if x = a.(m) then true
      else if x < a.(m) then doit l m
      else doit (m + 1) r
    end
  in
  doit 0 (Array.length a)

let () =
  let read_seq () = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
  let _ = read_int () in
  let s = Array.of_list (read_seq ()) in
  let _ = read_int () in
  let t = read_seq () in
  Printf.printf "%d\n" (List.fold_left (fun acc e -> acc + (if bin_search e s then 1 else 0)) 0 t)

Measured memory_bytes: 16244
#include "bits/stdc++.h"
#define inf 0x3f3f3f3f
#define pb push_back
#define vi vector<int>
#define fi first
#define se second 
#define mp make_pair
typedef unsigned long long ull;
//typedef pair<int,int> P;
#define LL long long 
#define pi acos(-1)
#define MOD 998244353
typedef long long ll;
using namespace std;
const int maxn = 100005;
char b[maxn];
const char p[]="AGC";
int n,s[maxn],q;
int main(){
	int h,w,x,y;
	cin>>h>>w>>x>>y;
	cout<<h*w-x*w-h*y+x*y<<endl;


	return 0;
}


Measured memory_bytes: 256
using System;

class test
{
    public static void Main()
    {
        int[] n = new int[10];
        for (int i = 0; i < n.Length; i++)
        {
            n[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(n);
        Array.Reverse(n);
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine(n[i]);
        }
    }
}

Measured memory_bytes: 5760
N=int(input())
count=0
T,X,Y=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    if abs(x-X)+abs(y-Y)<=abs(t-T) and t%2==(x+y)%2:count+=1
    T,X,Y=t,x,y
print('Yes' if count==N else 'No')

Measured memory_bytes: 3060
use proconio::{input, fastout};

#[fastout]
fn main() {
  input! {
    n: usize,
    k: usize,
    vals: [isize;n]
  }
  
  let mut memo: Vec<isize> = vec![0;50];
  for &v in &vals {
    for i in 0..50 {
      if (v >> i) & 1 > 0 {
        memo[i] += 1;
      }
    }
  }

  let n = n as isize;
  let mut dp: Vec<(isize, isize)> = vec![(-1,0); 51];
  for i in (0..50).rev() {
    if dp[i+1].0 >= 0 {
      dp[i].0 = dp[i+1].0 + (std::cmp::max(memo[i], n-memo[i]) << i);
    }
    if (k >> i) & 1 > 0 {
      dp[i].0 = std::cmp::max(dp[i].0, dp[i+1].1 + (memo[i] << i));
      dp[i].1 = dp[i+1].1 + ((n - memo[i]) << i);
    } else {
      dp[i].1 = dp[i+1].1 + (memo[i] << i);
    }
  }
  println!("{}", std::cmp::max(dp[0].0, dp[0].1));
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long h, w; cin >> h >> w;
	if(h == 1 || w == 1){
		cout << 1 << endl;
		return 0;
	}
	cout << ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int N=200005;
int a[N],n,m,pre[N],next[N];
int main()
{
	scanf("%d%d",&n,&m);
	int head=1;
	for(int i=1;i<n;++i)
	{
		pre[i]=i-1;
		next[i]=i+1;
	}
	pre[n]=n-1;
	for(int i=1;i<=m;++i)
	{
		int x;
		scanf("%d",&x);
		if(x==head)
		continue;
		int prex=pre[x],nextx=next[x];
		next[prex]=nextx;
		pre[nextx]=prex;
		pre[x]=0;
		next[x]=head;
		pre[head]=x;
		head=x;
	//	printf("%d pre %d  next %d\n",head,pre[x],next[x]);
	}
/*	printf("%d\n",head);	
	for(int i=1;i<=n;++i)
	{
		printf("%d %d\n",pre[i],next[i]);
	}*/
	for(int p=head;p;p=next[p])
	printf("%d\n",p);
}
/*
10 8
1
4
7
3
4
10
1
3
*/

Measured memory_bytes: 4760
lr = input().split()
l = int(lr[0])
r = int(lr[1])

mini = 2018

for i in range(l, r+1):
  for j in range(i+1, r+1):
    mini = min(mini, (i*j)%2019)

    if mini==0:
      break
  if mini==0:
    break
print(mini)


Measured memory_bytes: 2940
n, a = map(int, input().split(" "))
list_x = [int(x) - a for x in input().split(" ")]
counts = [{} for i in range(n + 1)]
counts[0][0] = 1
for i, x in enumerate(list_x):
  for v in counts[i]:
    c = counts[i][v]
    if v not in counts[i + 1]:
      counts[i + 1][v] = 0
    counts[i + 1][v] += c
    if v + x not in counts[i + 1]:
      counts[i + 1][v + x] = 0
    counts[i + 1][v + x] += c
print(counts[n][0] - 1)


Measured memory_bytes: 4980
#include<bits/stdc++.h>
#define int long long
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
int s[3000];
 
signed main(){
	int n,m,k,a,b,c,t;
	scanf("%lld%lld%lld%lld%lld%lld%lld",&n,&m,&k,&a,&b,&c,&t);
	rep(i,m){
		scanf("%lld",&s[i]);s[i]--;
	}
	vector<int>v;
	int cnt=0;
	for(int i=0;i<m-1;i++){
		int d=s[i]*b;
		if(d>t)break;
		if(i)cnt++;cnt+=min(s[i+1]-s[i]-1,(t-d)/a);
		int pos=(t-d)/a+1;
		rep(j,k-m){
			if(s[i]+pos>=s[i+1])break;
			int u=t-(pos*c+d);
			if(u<0)break;
			int k=u/a;
			v.push_back(min(s[i+1]-(s[i]+pos),k+1));
			pos+=k+1;
		}
	}
	if(s[m-1]*b<=t)cnt++;
	sort(v.begin(),v.end(),greater<int>());
	rep(i,min((int)v.size(),k-m))cnt+=v[i];
	printf("%lld\n",cnt);
}

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

int H, sum, zero;
bool update;
int array[11][5];

int main()
{
	do
	{
		cin >> H;
		if (H == 0)break;
		for (int i = H - 1; i >= 0; i--)
			for (int j = 0; j < 5; j++)
				cin >> array[i][j];
		sum = 0;
		do
		{
			update = false;
			for (int i = 0; i < H; i++)
			{
				if (array[i][2] == 0)
					break;
				if (array[i][2] == array[i][0] && array[i][2] == array[i][1])
				{
					if (array[i][2] != array[i][3])
					{
						sum += array[i][2] * 3;
						array[i][0] = 0;
						array[i][1] = 0;
						array[i][2] = 0;
						update = true;
					}
					else if (array[i][2] != array[i][4])
					{
						sum += array[i][2] * 4;
						array[i][0] = 0;
						array[i][1] = 0;
						array[i][2] = 0;
						array[i][3] = 0;
						update = true;
					}
					else
					{
						sum += array[i][2] * 5;
						array[i][0] = 0;
						array[i][1] = 0;
						array[i][2] = 0;
						array[i][3] = 0;
						array[i][4] = 0;
						update = true;
					}
				}
				else if (array[i][2] == array[i][1] && array[i][2] == array[i][3])
				{
					if (array[i][2] != array[i][4])
					{
						sum += array[i][2] * 3;
						array[i][1] = 0;
						array[i][2] = 0;
						array[i][3] = 0;
						update = true;
					}
					else
					{
						sum += array[i][2] * 4;
						array[i][1] = 0;
						array[i][2] = 0;
						array[i][3] = 0;
						array[i][4] = 0;
						update = true;
					}
				}
				else if (array[i][2] == array[i][3] && array[i][2] == array[i][4])
				{
					sum += array[i][2] * 3;
					array[i][2] = 0;
					array[i][3] = 0;
					array[i][4] = 0;
					update = true;
				}
			}
			if (!update)break;
			for (int j = 0; j < 5; j++)
			{
				for (zero = 0; zero < H - 1; zero++)
					if (array[zero][j] == 0)
						break;
				for (int search = zero + 1; search < H; search++)
					if (array[search][j]>0)
					{
						array[zero][j] = array[search][j];
						array[search][j] = 0;
						zero++;
					}
			}
		} while (true);
		cout << sum << endl;
	} while (true);
	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;

ll n; map<int, int> dp;
ll sum(ll x) {
	if (dp[x]!=0) return dp[x];
	else return dp[x] = (sum(x / 2) + sum((x - 1) / 2) + sum((x - 2) / 2)) % mod;
}

int main() {
	cin >> n;
	dp[0] = 1, dp[1] = 2;
	cout << sum(n) << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	Scanner sc;

	private Main(){
		sc = new Scanner( System.in );
	}

	private void run(){
		int rect = 0;
		int dia = 0;

		while( sc.hasNext() ){
			String str = sc.next();
			String[] sideStr = str.split( "," );
			int[] side = new int[ 3 ];

			for( int i = 0; i < sideStr.length; i++ ){
				side[ i ] = Integer.parseInt( sideStr[ i ]);
			}

			if( side[ 0 ] * side[ 0 ] + side[ 1 ] * side[ 1 ] == side[ 2 ] * side[ 2 ] ){
				rect++;
			}else if( side[ 0 ] == side[ 1 ] ){
				dia++;
			}
		}
		System.out.println( rect );
		System.out.println( dia );
	}

	public static void main( String[] args ){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

const int MAX = 1100000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    int X,Y;cin>>X>>Y;
    if(X<Y)swap(X,Y); //X>=Y
    int flag=0,p,q;
    rep(i,X/2+1){
        if(i+2*(X-2*i)==Y){
            p=i;q=X-2*i;
            flag++;
        }
    }
    if(flag==0){
        cout<<0<<endl;
        return 0;
    }
    COMinit();
    cout << COM(p+q, p) << endl;
    
    return 0;
}

Measured memory_bytes: 25984
N = int(input())
Ss = input()

ans = 0
for i in range(1, N):
    S1s = Ss[:i]
    S2s = Ss[i:]
    num = 0
    for ch in 'abcdefghijklmnopqrstuvwxyz':
        if ch in S1s and ch in S2s:
            num += 1
    ans = max(ans, num)
print(ans)


Measured memory_bytes: 2940