akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

// chmin, chmax関数

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

int main(){
    VI c(100010, 0);
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        c[a]++;
    }

    int max = 0;
    rep2(i,1,100000){
        chmax(max, c[i-1]+c[i]+c[i+1]);
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = int(1e+9 + 7)
a = sorted(a)

kai = [1]*(n+1)
gyaku = [1]*(n+1)

for i in range(2, n+1):
    kai[i] = kai[i-1]*i % mod
    gyaku[i] = gyaku[i-1]*pow(i, mod-2, mod) %mod

answer = 0
for i in range(k-1,n):
    answer = (answer + a[i] * kai[i] * gyaku[(i)-(k-1)] * gyaku[k-1]) % mod

answer2 = 0
for i in range(n-k+1):
    answer2 = (answer2 + a[i] * kai[n-i-1] * gyaku[(n-i)-k] * gyaku[k-1]) % mod


if k == 1:
    print(0)
else:
    print((answer - answer2)%mod)


Measured memory_bytes: 63344
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        long K = sc.nextLong();
        sc.close();

        if (isAllSame(S)) {
            System.out.println(S.length() * K / 2);
            return;
        }
        if (S.charAt(0) != S.charAt(S.length()-1)) {
            System.out.println(NotContinue(S.charAt(0), S, K));
            return;
        }
        int FrontLength = getSameLength(S, S.charAt(0), 0, 1);
        int BackLength = getSameLength(S, S.charAt(S.length()-1), S.length()-1, -1);
        System.out.println(NotContinue(S.charAt(0), S, K) + ((FrontLength + BackLength) / 2 - (FrontLength / 2) - (BackLength / 2)) * (K - 1));
        return;   
    }
    public static boolean isAllSame(String S) {
        if (S.length() == getSameLength(S, S.charAt(0), 0, 1)) {
            return true;
        }
        return false;
    }
    public static int getSameLength(String S, char a, int index, int add) {
        if (index < 0 || index >= S.length()) {
            return 0;
        }
        if (S.charAt(index) == a) {
            return 1 + getSameLength(S, a, index + add, add);
        }
        return 0;
    }
    public static long NotContinue(char a, String S, long K) {
        if (S.length() < 2) {
            return 0;
        }
        if (S.charAt(0) == S.charAt(1)) {
            if (S.length() >= 3) {
                return K + NotContinue(a, GetDiffString(S.charAt(0), S.charAt(2)) + S.substring(2), K);
            }
            return K + NotContinue(a, GetDiffString(S.charAt(0), a) + S.substring(2), K);
        }
        return NotContinue(a, S.substring(1), K);
    }
    public static String GetDiffString(char a, char b) {
        String alphabet = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < alphabet.length(); i++) {
            if(a != alphabet.charAt(i) && b != alphabet.charAt(i)) {
                return alphabet.substring(i, i+1);
            }
        }
        return "a";
    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector<int> suf(n);
    suf[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; --i)
        suf[i] = max(suf[i + 1], a[i]);
    int r = -1;
    for (int i = 0; i < n - 1; ++i)
        if (suf[i + 1] > a[i])
            r = max(r, suf[i + 1] - a[i]);
    int odp = 0;
    for (int i = 0; i < n - 1; ++i)
        if (suf[i + 1] == a[i] + r)
            ++odp;
    cout << odp;
    return 0;
}


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

int main() {
 long int a, b, c, d, e, f;
 cin >> a >> b >> c;
 if (a == 0) cout << c << endl;
 else if(a>0){
   d = a/c;
   if(d>=b) cout << a - (b*c) << endl;
   else{
      if(b%2==d%2){
       e = a - (c*d);
       f = a - (c*(d+2));
       cout << min(abs(e),abs(f)) << endl;
     }
     else{
      e = a - (c*(d-1));
      f = a - (c*(d+1));
      cout << min(abs(e),abs(f)) << endl;
     }
 }
   }
  else {
   d = -a/c;
   if(d>=b) cout << abs((b*c) + a) << endl;
   else if(b%2==d%2){
     e = (c*d) + a;
     f = (c*(d+2)) + a;
     cout << min(abs(e),abs(f))  << endl;
     }
     else{
     e = (c*(d-1)) + a;
     f = (c*(d+1)) + a;
     cout << min(abs(e),abs(f))  << endl;
   }
  }
   }

Measured memory_bytes: 3516
# https://atcoder.jp/contests/arc099/tasks/arc099_a
n, k = map(int, input().split())
nums = [int(i) for i in input().split()]

ans = (len(nums) - 1) // (k - 1)
if (len(nums) - 1) % (k - 1) != 0:
    ans += 1
print(ans)

Measured memory_bytes: 52780
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: i64 = sc.cin();
    put!((1..n).sum::<i64>());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef  long long   ll;
ll inf=1000000000000000000,mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        ll n,m,x;
        cin>>n>>m>>x;
        ll arr[n][m+1];
        for(ll i=0;i<n;i++){
            for(ll j=0;j<m+1;j++)
            cin>>arr[i][j];
        }
        ll sum,freq[m],mi=inf,flg;
        for(ll i=0;i<(1<<n);i++){flg=0;
            sum=0;
            for(ll j=0;j<m;j++)freq[j]=0;
            for(ll j=0;j<n;j++){
                if((1<<j)&i){
                    sum+=arr[j][0];
                    for(ll k=0;k<m;k++){
                        freq[k]+=arr[j][k+1];
                    }
                }
            }
            for(ll j=0;j<m;j++){
                if(freq[j]<x)
                flg=1;
            }
            if(flg==0){
                mi=min(mi,sum);
            }
        }
        if(mi==inf)
        cout<<"-1"<<endl;
        else
        cout<<mi<<endl;

}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;

const int MAXN = 1000*1000 + 7;
const int SS = 1<<20;
const int MOD = 998244353;

bool bylo[MAXN];
int ind[MAXN];
long long poprz[MAXN];
long long ile[MAXN];
long long n, x, m;

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

	int T;
	//cin >> T;
	T = 1;
	while(T--)
	{
		cin >> n >> x >> m;
		long long a = x;

		long long sum = 0;
		long long i = 0;
		long long last = 100000 + 7;
		while( bylo[a] == false )
		{
			bylo[a] = true;
			poprz[a] = last;
			sum += a;
			ile[a] = sum;
			ind[a] = i;
			last = a;
			a = (a*a) % m;
			i++;
			if( i >= n )
				break;
		}
		long long d = i - ind[a];
		sum += (sum - ile[poprz[a]]) * ((n-i)/d);
		n = (n-i)%d;
		for(long long j=1; j<=n; j++)
		{
			sum += a;
			a = (a*a) % m;
		}
		cout << sum << '\n';
	}
	return 0;
}


Measured memory_bytes: 5664
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools

#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

n = int(input())
S = [str(input()) for x in range(n)]
S_set = set(S)
ans = 0

print(len(S_set))


Measured memory_bytes: 108436
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,j,k,l,n,m;
    cin>>n>>m;
    if(n+m>=10)
    cout<<"error"<<endl;
    else cout<<n+m<<endl;

    return 0;
}





Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
priority_queue <pair<LL,LL> > carib,caric;
priority_queue <int,vector<int>,greater<int> > terkecilb,terkecilc;
int a[100005],b[100005],c[100005],n,val[100005],x,y,z,totalb=0,totalc=0,kuranb,kurangc;
bool terambil[100005];
LL ans=0;
int main()
{
	memset(terambil,false,sizeof(terambil));
	scanf("%d%d%d",&x,&y,&z);
	n=x+y+z;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		ans+=(LL) a[i];
		val[i]=a[i];
	}
	for(int i=1;i<=n;i++)
		carib.push(mp(b[i]-a[i],i));
	for(int i=1;i<=n;i++)
		caric.push(mp(c[i]-a[i],i));
	while(totalb+totalc<y+z)
	{
		while(terambil[carib.top().se])
			carib.pop();
		while(terambil[caric.top().se])
			caric.pop();
		int kurangb=(totalb==y)?terkecilb.top():0;
		int kurangc=(totalc==z)?terkecilc.top():0;
		if(carib.top().fi-kurangb>caric.top().fi-kurangc)
		{
			pii tops=carib.top();
			carib.pop();
			terambil[tops.se]=true;
			ans+=tops.fi-kurangb;
			//cout<<"gak ambil "<<tops.se<<endl;
			if(totalb==y)
			{
				terkecilb.pop();
				totalc++;
			}
			else
			{
				totalb++;
			}
			terkecilb.push(b[tops.se]-c[tops.se]);
		}
		else
		{
			pii tops=caric.top();
			caric.pop();
			terambil[tops.se]=true;
			ans+=tops.fi-kurangc;
			//cout<<"gak ambil "<<tops.se<<endl;
			if(totalc==z)
			{
				terkecilc.pop();
				totalb++;
			}
			else
			{
				totalc++;
			}
			terkecilc.push(c[tops.se]-b[tops.se]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N;
    cin >> N;
    int A = (N + 3) / 4,B = (N + 6) / 7;
    bool ans = false;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            if (4 * i + 7 * j == N) {
                ans = true;
            }
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
  string S; cin >> S;
  string zeroone("01");
  string onezero("10");
  rep(i,50000) zeroone += "01";
  rep(i,50000) onezero += "10";
  int count01 = 0;
  int count10 = 0;
  rep(i,S.size()){
    if(S[i] != zeroone[i]) count01 += 1;
    else if (S[i] != onezero[i]) count10 += 1;
  }
  cout << min(count01,count10) << endl;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>N>>K;
    vector<mat> memo(2,mat(K, vec(K,0))), sum(2,mat(K+1, vec(K+1,0)));
    ll K2 = K*2;
    char c;
    rep(i,N){
        cin>>A>>B>>c;
        ll white = (c == 'W');
        A %= K2; B %= K2;
        (white += A/K + B/K)%=2;
        ++memo[white][A%K][B%K];
    }
    rep(i,2){
        rep(j,K){
            rep(k,K){
                ll temp = memo[i][j][k];
                temp += sum[i][j+1][k];
                temp += sum[i][j][k+1];
                temp -= sum[i][j][k];
                sum[i][j+1][k+1] = temp;
            }
        }
    }
    /*rep(i,2){
        rep(k,K+1){
            rep(j,K+1) cout<<sum[i][j][k]<<' ';
            cout<<endl;
        }
        cout<<endl;
    }*/
    ll ans = 0;
    rep(i,K+1){
        rep(j,K+1){
            ll temp = sum[0][i][j];
            temp += sum[1][i][K] - sum[1][i][j];
            temp += sum[1][K][j] - sum[1][i][j];
            temp += sum[0][K][K] - sum[0][i][K] - sum[0][K][j] + sum[0][i][j];
            ans = max(ans, temp);
        }
    }
    rep(i,K+1){
        rep(j,K+1){
            ll temp = sum[1][i][j];
            temp += sum[0][i][K] - sum[0][i][j];
            temp += sum[0][K][j] - sum[0][i][j];
            temp += sum[1][K][K] - sum[1][i][K] - sum[1][K][j] + sum[1][i][j];
            ans = max(ans, temp);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 39552
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int ans = 0;
   rep(i, 0, s.size()) {
      if (s[i] != s[s.size() - 1 - i]) ans++;
   }
      cout << (ans+1)/ 2 << endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int N, K, S;
	scanf("%d", &N);
	scanf("%d", &K);
	scanf("%d", &S);
	for (int i = 0; i < N; i++) {
		if (i < K)printf("%d ", S);
		else printf("%d ", (S + 1) % 1000000000);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cmath>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 200200;

int par[ms];
std::pair<long long, int> best[ms];

int getPar(int x) { return x == par[x] ? x : par[x] = getPar(par[x]); }
bool makeUnion(int a, int b) {
	a = getPar(a), b = getPar(b);
	if(a == b) return false;
	par[a] = b;
	return true;
}


int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	long long d;
	std::cin >> n >> d;
	std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		par[i] = i;
		a[i] = rng() % (int)(1e9) + 1;
		std::cin >> a[i];
	}
	//auto getCost = [&](int i, int j) { return std::max(i-j,j-i) * d + a[i] + a[j]; };
	int got = 0;
	long long ans = 0;
	const long long INF = 5e9;
	while(got < n - 1) {
		//std::cout << "running the loop!" << std::endl;
		std::vector<std::pair<long long, int>> wtf;
		for(int i = 0; i < n; i++) {
			best[i] = std::pair<long long, int>(INF, -1);
		}
		// go prefix
		for(int i = 0; i < n; i++) {
			int j = 0;
			while(j < (int) wtf.size() && wtf[j].second == getPar(i)) j++;
			if(j < (int) wtf.size()) {
				auto p = wtf[j];
				p.first += a[i] + i * d;
				best[getPar(i)] = std::min(best[getPar(i)], p);
			}
			j = 0;
			while(j < (int) wtf.size() && wtf[j].second != getPar(i)) j++;
			if(j == (int) wtf.size()) {
				wtf.emplace_back(- i * d + a[i], getPar(i));
			} else {
				wtf[j] = std::min(wtf[j], std::pair<long long, int>(- i * d + a[i], getPar(i)));
			}
			std::sort(wtf.begin(), wtf.end());
			if(wtf.size() > 2) {
				wtf.pop_back();
			}
		}
		// go suffix
		wtf.clear();
		for(int i = n-1; i >= 0; i--) {
			int j = 0;
			while(j < (int) wtf.size() && wtf[j].second == getPar(i)) j++;
			if(j < (int) wtf.size()) {
				auto p = wtf[j];
				p.first += a[i] - i * d;
				best[getPar(i)] = std::min(best[getPar(i)], p);
			}
			j = 0;
			while(j < (int) wtf.size() && wtf[j].second != getPar(i)) j++;
			if(j == (int) wtf.size()) {
				wtf.emplace_back(i * d + a[i], getPar(i));
			} else {
				wtf[j] = std::min(wtf[j], std::pair<long long, int>(i * d + a[i], getPar(i)));
			}
			std::sort(wtf.begin(), wtf.end());
			if(wtf.size() > 2) {
				wtf.pop_back();
			}
		}
		// go edges
		for(int i = 0; i < n; i++) {
			if(getPar(i) == i) {
				//std::cout << "best for component of " << i << " is to " << best[i].second << " with cost " << best[i].first << "\n";
				if(makeUnion(i, best[i].second)) {
					ans += best[i].first;
					got++;
				}
			}
		}
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 5248
package main

import (
	"fmt"
	"io"
	"math"
	"os"
)

func assert(x bool) {
	if !x {
		panic("assertion failed")
	}
}

type Scanner struct {
	is     io.Reader
	buffer [1 << 16]byte
	size   int
	pos    int
}

func NewScanner(in io.Reader) *Scanner {
	return &Scanner{is: in}
}

func (s *Scanner) nextChar() int {
	if s.pos >= s.size {
		var err error
		s.size, err = s.is.Read(s.buffer[:])
		s.pos = 0
		if err == io.EOF {
			return -1
		}
	}
	assert(s.pos < s.size)
	c := s.buffer[s.pos]
	s.pos++
	return int(c)
}

const BitsPerInt = 32 << uint(^uint(0)>>63)

const MinInt = -1 << (BitsPerInt - 1)

const MaxInt = -(MinInt + 1)

func (s *Scanner) NextInt() int {
	c := s.nextChar()
	for c == ' ' || c == '\r' || c == '\n' || c == '\t' {
		c = s.nextChar()
	}
	if c == '-' {
		c = s.nextChar()
		assert('0' <= c && c <= '9')
		n := -(c - '0')
		c = s.nextChar()
		for '0' <= c && c <= '9' {
			d := c - '0'
			c = s.nextChar()
			assert(n > MinInt/10 || n == MinInt/10 && d <= -(MinInt%10))
			n = n*10 - d
		}
		return n
	} else {
		assert('0' <= c && c <= '9')
		n := c - '0'
		c = s.nextChar()
		for '0' <= c && c <= '9' {
			d := c - '0'
			c = s.nextChar()
			assert(n < MaxInt/10 || n == MaxInt/10 && d <= MaxInt%10)
			n = n*10 + d
		}
		return n
	}
}

func main() {
	in := NewScanner(os.Stdin)
	n := in.NextInt()

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = in.NextInt()
	}

	i := n - 1
	for ; i >= 0; i -= 2 {
		fmt.Printf("%d ", arr[i])
	}
	for i = int(math.Abs(float64(i + 1))); i < n; i += 2 {
		fmt.Printf("%d ", arr[i])
	}
}


Measured memory_bytes: 5760
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    ll g = 0;
    map<int,int> f;
    for(int i = 0 ; i < n; i++){
        ll k; cin>>k;
        g = __gcd(g,k);
        for(int i = 2; i*i <= k; i++){
            if(k%i==0){
                f[i]++;
                while(k%i==0){
                    k/=i;
                }
            }
        }
        if(k>=2)
            f[k]++;
    }
    if(g!=1){
        cout<<"not coprime"<<endl;
    }
    else{
        bool single = true;
        for(auto pp : f){
            if(pp.ss>1)
                single = false;
        }
        if(!single){
            cout<<"setwise coprime"<<endl;
        }
        else{
            cout<<"pairwise coprime"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7312
def add_each_number(num):
  s = str(num)
  array = list(map(int, s))
  return sum(array)
 
num = input()
while len(str(num)) > 1:
  num = add_each_number(num)

if int(num) == 0 or int(num) == 9:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 75796
#include <iostream>
#include <vector>

int main()
{
    int N, M;

    std::cin >> N >> M;
    std::vector<bool> is_correct(N);

    int ac_count_all = 0;
    std::vector<int> wa_count(N);
    for (int i = 0; i < M; i++) {
        int p;
        std::string S;
        std::cin >> p >> S;
        p--;

        if (is_correct[p])
            continue;

        if (S == "WA")
            wa_count[p]++;
        else {
            is_correct[p] = true;
            ac_count_all++;
        }
    }

    int wa_count_all = 0;
    for (int i = 0; i < N; i++) {
        if (is_correct[i]) {
            wa_count_all += wa_count[i];
        }
    }

    std::cout << ac_count_all << " " << wa_count_all << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll K, A, B;
    cin >> K >> A >> B;
    for (int i = 1; i <= 1000; i++) {
        if (A <= K * i && K * i <= B) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}



Measured memory_bytes: 3132
#include<stdio.h>

int main()
{	
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a <= b && b <= c) {
		printf("%d %d %d\n",a,b,c);
	} else if (a <= c && c <= b) {
		printf("%d %d %d\n",a,c,b);
	} else if (b <= a && a <= c) {
		printf("%d %d %d\n",b,a,c);
	} else if (b <= c && c <= a) {
		printf("%d %d %d\n",b,c,a);
	} else if (c <= a && a <= b) {
		printf("%d %d %d\n",c,a,b);
	} else if (c <= b && b <= a) 
		printf("%d %d %d\n",c,b,a);
	return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<long long> Divisor(long long n) {
    vector<long long> ret;
    for(long long i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main(void) {
    long long N; cin >> N;
    auto divisor = Divisor(N);
    Int ans = 1e15;
    for (int i = 0; i < divisor.size(); i++) {
        long long I = divisor[i];
        long long J = N/I;
        ans = min((I-1) + (J-1), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];
	vector<vector<int>> dp((1<<n)+1,vector<int>(55,INF));
	dp[0][0]=0;
	rep(i,1<<n){
		int cnt=__builtin_popcount(i);//並びが決まっているカードの個数
		int now=cnt;
		vector<Pi> ret;
		rep(j,n){
			if(!(i & (1<<j))){//並びがまだ決まってないカード
				ret.push_back(Pi(j,now++));//それが現在左から何番目にあるか
			}
		}
		rep(j,55){
			if(dp[i][j]>=INF) continue;
			for(auto itr:ret){
				int ne;
				if(abs(itr.fi-cnt)%2==0) ne=a[itr.fi];
				else ne=b[itr.fi];
				if(ne>=j){
					chmin(dp[i|(1<<itr.fi)][ne],dp[i][j]+abs(itr.se-cnt));
				}
			}
		}
	}
	int ans=INF;
	rep(j,55){
		chmin(ans,dp[(1<<n)-1][j]);
	}
	if(ans<INF) cout<<ans<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 67840
N, M = gets.split.map(&:to_i)

prefCityNo = Array.new(N+1, 1)

cityInfo = [*0...M].map{ |i| gets.split.map(&:to_i) + [i] }.sort_by{|info| info[1] } # 誕生年でソート
cityNames = cityInfo.map{|info|
    prefNo = info[0]
    id = "%#06d" % prefNo + "%06d" % prefCityNo[prefNo]
    prefCityNo[prefNo] += 1
    [id, info[2]]
}

cityNames.sort_by{|name| name[1]}.each{|name|
    puts name[0]
}


Measured memory_bytes: 29216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define MP make_pair
#define PII pair<int, int>
typedef long long LL;
const LL P = 998244353;
const int INF = 0x3fffffff;
const int N = 200010;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int m,d,ans=0;

int main(){
	//freopen("test.in","r",stdin);
	cin>>m>>d;
	rep(i,1,m){
		rep(j,1,d){
			int x=j/10, y=j%10;
			if(x>=2 && y>=2 && x*y==i) ++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

  string s;
  cin >> s;

  int l = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == ')') l++;
    else l--;
    l = max(0, l);
  }

  int r = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '(') r++;
    else r--;
    r = max(0, r);
  }

  cout << string(l, '(') << s << string(r, ')') << endl;
}


Measured memory_bytes: 256
n = int(input())
s = list()
for i in range(n):
    s.append(list(input()))

t = dict()
l = 0

for i in range(len(s)):
    s[i].sort()
    k = "".join(s[i])
    if not k in t.keys():
        t[k] = 1
    else:
        t[k] += 1
        l += t[k] - 1

print(l)

Measured memory_bytes: 39040
#include <stdio.h>

int main(void)
{
	int t[4];
	int i;
	int sum;
	int m, s;
	
	sum = 0;
	for (i = 0; i < 4; i++){
		scanf("%d", &t[i]);
		sum += t[i];
	}
	m = sum / 60;
	s = sum % 60;
	
	printf("%d\n%d\n", m, s);
	
	return (0);
}

Measured memory_bytes: 1024
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int sum = 0;
		for(int i=0; i<n; i++){
			int x, y, h, w;
			cin >> x >> y >> h >> w;

			int z = x+y+h;
			if(z<=60&&w<=2){
				sum += 600;
			}
			else if(z<=80&&w<=5){
				sum += 800;
			}
			else if(z<=100&&w<=10){
				sum += 1000;
			}
			else if(z<=120&&w<=15){
				sum += 1200;
			}
			else if(z<=140&&w<=20){
				sum += 1400;
			}
			else if(z<=160&&w<=25){
				sum += 1600;
			}
		}

		cout << sum << endl;
	}

	return 0;
}

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

const int MOD = 1000000007;

int main() {
    ll n, x, y,z;
    cin >> n;
     x = 1;
     y = 1;
     z = 1;
     rep(i, n) {
            x = (x * 10) % MOD;
     }
     rep(j, n) {
           y = (y * 9) % MOD;
     }
     y = (2*y) % MOD;
     rep(k, n) {
         z = (z * 8) % MOD;
     }
     z = (MOD + x - y + z)%MOD;
     cout<<z<<endl;
    return 0;
}

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



int main() {
	

	long long N, A, B,ans;
	cin >> N >> A >> B;

	ans = N / (A + B)*A;

	if (N % (A + B) >= A)
	{
		ans += A;
	}
	else
	{
		ans += N % (A + B);
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
/*
	ID: Loxilante
	Time: 2020/08/
	Prog: 
	Lang: cpp
*/
#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3")
#endif
#include <bits/extc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...) 97
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn = int> inline tn next(void) { tn k; cin>>k; return k; }
const int U = 3e5;
const int mod = 1000000007;
int sum[U], w[U];
inline int SUM(int i, int j)
{
	return sum[j] - sum[i-1];
}
signed main(void)
{
	clock_t Begin = clock();

	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n = next(), ans = 0;
	hrp(i, 1, n) cin>>w[i];
	
	clock_t InputFinished = clock();
	
	hrp(i, 1, n) sum[i] = (sum[i-1]+w[i])%mod; // 1 2 3 4 5: 1 3 6 10 15

	hrp(i, 1, n-1)
		ans = (ans+w[i]*SUM(i+1, n))%mod;

	cout<<(ans+mod)%mod<<endl;
	
	clock_t End = clock();
	
	D((double)(End-Begin)/CLOCKS_PER_SEC);
	D((double)(End-InputFinished)/CLOCKS_PER_SEC);
	
	return 0;
}
/*

 */

Measured memory_bytes: 6772
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    ll X;
    cin >> X;
    ll S = 100;
    ll cnt = 0;

    while(true) {
        if(S >= X) break;
        S *= 1.01;
        cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    int r;
    cin >> r;
    cout << 3 * r *r << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才的ですよね

ll num[2000000];
const int ma = (1 << 19) - 1;
bool query(ll n) {
	int n2 = (n * 3 & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return 1;
		n2++;
	}
	return 0;
}
void add(ll n) {
	int n2 = (n * 3 & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			return;
		}
		n2++;
	}
	num[n2] = n + 1;
}

int KH[300001], KW[300001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int H, W, M;
	cin >> H >> W >> M;

	rep(i, M) {
		int h, w;
		cin >> h >> w;

		KH[h]++;
		KW[w]++;
		add(ll(h) * W + w);
	}

	int saidaih = -1;
	int hh[300001], h = 0;
	rep1(i, H) {
		if (saidaih < KH[i]) {
			saidaih = KH[i];
			h = 1;
			hh[0] = i;
		}
		else if (saidaih == KH[i]) {
			hh[h++] = i;
		}
	}
	int saidaiw = -1;
	int ww[300001], w = 0;
	rep1(i, W) {
		if (saidaiw < KW[i]) {
			saidaiw = KW[i];
			w = 1;
			ww[0] = i;
		}
		else if (saidaiw == KW[i]) {
			ww[w++] = i;
		}
	}

	if (ll(h) * w > M) {
		co(saidaih + saidaiw);
		return 0;
	}
	int atta = 0;
	rep(i, h) rep(j, w) {
		if (!query(ll(hh[i]) * W + ww[j])) {
			atta = 1;
			break;
		}
	}

	if (atta) co(saidaih + saidaiw);
	else co(saidaih + saidaiw - 1);

	Would you please return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, p, q, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c;
	cin>>a>>b;
	cout<<(3*a + b)/2;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

/**
 * Walk on Multiplication Table
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long N = sc.nextLong();

            long ans = Long.MAX_VALUE;
            for (long n = 1; n <= Math.sqrt(N); n++) {
                if (N % n != 0) {
                    continue;
                }

                ans = Math.min(ans, n + N / n - 2);
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

#if DEBUG
const int MAX = 10;
#else
const int MAX = 510;
#endif

int D[MAX][MAX] = {};
int H, W;

bool A[MAX][MAX] = {};

signed main() {
	cin >> H >> W;
	rep(i, 0, H)rep(j, 0, W) {
		cin >> D[i][j];
	}
	rep(i, 0, H)rep(j, 0, W) {
		if (D[i][j]) {
			A[i + 1][j + 1] = true;
			int d = D[i][j];
			rep(ii, i, i + 3)rep(jj, j, j + 3) {
				D[ii][jj] -= d;
			}
		}
	}
	rep(i, 0, H)dumpc(A[i]);
	vector<pii> v;
	rep(i, 0, H)rep(j, 0, W) {
		if (!A[i][j])continue;
		int cnt = 0;
		rep(ii, i - 1, i + 2)rep(jj, j - 1, j + 2) {
			if (A[ii][jj])cnt++;
		}
		if (cnt == 2)v.emplace_back(pii(i, j));
		if (cnt == 1) {
			v.emplace_back(pii(i, j));
			v.emplace_back(pii(i, j));
		}
	}
	dump(v.size());
	sort(all(v));
	cout << v[1].first << " " << v[1].second << " " << v[0].first << " " << v[0].second << endl;
	return 0;
}

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

int main()
{
	while (true) {
		int N, Q;
		cin >> N >> Q;

		if (N == 0 && Q == 0) {
			break;
		}

		vector<string> names(N);
		vector<int> based(N);
		vector<int> year(N);

		for (int i = 0; i < N; i++) {
			cin >> names[i] >> based[i] >> year[i];
		}


		for (int i = 0; i < Q; i++) {
			int query;
			cin >> query;

			int ans_year = -1;
			string ans_name;

			for (int j = 0; j < N; j++) {
				if (year[j] < query) {
					continue;
				}

				int temp = based[j] - (year[j] - query);

				if (temp < 1) {
					continue;
				}
				else {
					ans_name = names[j];
					ans_year = temp;
					break;
				}
			}

			if (ans_year == -1) {
				cout << "Unknown" << endl;
			}
			else {
				cout << ans_name << " " << ans_year << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3268
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

#define MAX 302

Int RF[MAX][MAX];
Int RG[MAX][MAX];
int C[MAX][MAX];
int N, K, M;

Int f(int digits, int places);
Int g(int digits, int places)
{
	if (places == 0) return 1;
	Int& res = RG[digits][places];
	if (res != -1) return res;

	res = 0;
	int i;
	FOR(i, 0, places)
	{
		Int t = f(digits, i)*g(digits, places - 1 - i) % M;
		res = (res + t*C[places - 1][i]) % M;
	}

	return res;
}

Int f(int digits, int places)
{
	if (digits <= 0) return 0;
	Int& res = RF[digits][places];
	if (res != -1) return res;
	return res = (f(digits - 1, places) + g(digits - 1, places)) % M;
}

int main()
{
	scanf("%d%d%d", &N, &K, &M);
	CLEAR(RF, -1);
	CLEAR(RG, -1);

	int i, j;
	FOR(i, 0, MAX) C[i][i] = C[i][0] = 1;
	FOR(i, 0, MAX)
		FOR(j, 1, i)
		C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % M;

	printf("%lld\n", g(K, N));
	return 0;
};


Measured memory_bytes: 2048
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int sum = 0;

        if (A > B) {
            sum += A;
            A -= 1;
        } else {
            sum += B;
            B -= 1;
        }

        if (A > B) {
            sum += A;
        } else {
            sum += B;
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 23508
#include<iostream>
#include<vector>
using namespace std;
int zet(int a) {
	if (a < 0) {
		return -a;
	}
	else {
		return a;
	}
}
int main() {
	int n; cin >> n;
	int l; cin >> l;
	vector<int> taste;
	int azi = 0;
	int min = l;
	for (int i = 0; i < n; i++) {
		taste.push_back(l + (i + 1) - 1);
		
		azi += l + (i + 1) - 1;
		if (zet(taste[i]) <= zet(min)) {
			min = taste[i];
		}
	}
	cout << azi - min;
	return 0;
}

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

int main() {

 int A, B, C;
  cin >> A >> B >> C;
  if (A == 7 && B == 5 && C == 5 || A == 5 && B == 7 && C == 5 ||
     A == 5 && B == 5) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9+7
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
 
 
int main(){
    string s;
    cin>>s;
    int a;
    if(s=="SUN") a=7;
    else if(s=="MON") a=6;
    else if(s=="TUE") a=5;
    else if(s=="WED") a=4;
    else if(s=="THU") a=3;
    else if(s=="FRI") a=2;
    else if(s=="SAT") a=1;

    cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n, k;   cin >> n >> k;
    vector<int> sunuke(n,0);
    for (int i = 0; i < k; i++) {
        int d;  cin >> d;
        for (int j = 0; j < d; j++) {
            int a;  cin >> a;
            a--;
            sunuke[a]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (sunuke[i] == 0)
            ans++;
    }

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

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	long double n, m, d;
	cin >> n >> m >> d;
	long double ans = 0;
	if (d == 0) {
		ans = (m-1) * 1/n;
	} else {
		ans = (m - 1) * (2 * (n - d)) / (n * n);
	}
	cout << setprecision(16) << ans << endl;
	return 0;
}

Measured memory_bytes: 3820