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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int n,y;
	cin>>n>>y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(i+j>n)continue;
			int k=n-i-j;
			int sum=10000*i+5000*j+1000*k;
			if(sum==y){
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
	return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  bool f = false;
  for(int i = 0; i != (int)s.length(); i++){
    auto x = s.front();
    s.erase(begin(s));
    s += x;
    
    if(s == t){
      f = true;
      break;
    }
  }
  
  if(f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    for (int i=1; i<n; i++) {
        a.at(i) += a.at(i-1);
    }
    ll ans = LINF;
    for (int i=0; i<n-1; i++) {
        chmin(ans, abs(a.back() - 2 * a.at(i)));
    }
    cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	A,B,T = map(int, input().split(" "))

	tmp = T // A
	ans = tmp * B


	print(ans)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3444
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toLong
  
  def solve(x: Long): Long = x % (scala.math.pow(10, 9) + 7).toLong
  
  def fact(i: Long, before: Long): Long = {
    if (i == n) solve(before * n)  
    else fact(i + 1, solve(i * before))
  }

  println(fact(1, 1))
  
}

Measured memory_bytes: 25408
import sys
ab=input().rstrip().split(" ")
a=int(ab[0])
b=int(ab[1])
if a>=b:
    l=a
    s=b
elif a<b:
    l=b
    s=a
for i in range(1,s+1):
    u=i*l
    if u%s==0:
        ans=u
        print(ans)
        sys.exit()

Measured memory_bytes: 38640
fun main(args: Array<String>) {
  val X = readInts()
  for (i in 0..4) {
    if (X[i] == 0) {
      println(i + 1)
    }
  }
}

fun myBinarySearch(begin: Int, end: Int, isOk: (key: Int) -> Boolean): Int {
  var ng = begin
  var ok = end

  while (Math.abs(ok - ng) > 1) {
    val mid = (ok + ng) / 2
    if (isOk(mid)) {
      ok = mid
    } else {
      ng = mid
    }
  }

  return ok
}

fun <T> List<T>.myBinarySearch(isOk: (T) -> Boolean): Int {
  return myBinarySearch(-1, size) { index -> isOk(get(index)) }
}

fun <T> Array<T>.myBinarySearch(isOk: (T) -> Boolean): Int {
  return myBinarySearch(-1, size) { index -> isOk(get(index)) }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 36420
#[allow(unused_imports)]
use std::cmp;

macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut 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! 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")
  };
}

fn main() {
  input!{
    n: usize,
    xs: [i32; n],
  }
  let mut ys = xs.clone();
  ys.sort();
  let med_h = ys[n/2];
  let med_l = ys[n/2-1];
  for x in xs {
    let med = if x >= med_h {
      med_l
    } else {
      med_h
    };
    println!("{}", med);
  }
}


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

long long max(long long a) {
  return a > 0 ? a : -a;
}

int main() {
  int N;
  cin >> N;
  long long min = 10000000000;
  long long sum = 0;
  long long neg = 0;
  bool has_zero = false;
  for (int i = 0; i < N; i++) {
    long long tmp;
    cin >> tmp;
    if (tmp == 0) {
      has_zero = true;
    } else if (tmp < 0) {
      neg++;
      sum += -tmp;
      min = -tmp > min ? min : -tmp;
    } else {
      sum += tmp;
      min = tmp > min ? min : tmp;
    }
  }
  
  if (!has_zero && neg % 2 != 0) {
    sum -= 2*min;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b <= a) {
            System.out.println("delicious");
        } else if (b <= a + x) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner (System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int count = a/d;
        int s = c/b;
        if(a%d!=0) count++;
        if(c%b!=0) s++;
        if(s>count) System.out.println("No");
        else System.out.println("Yes");
    }
}

Measured memory_bytes: 35716
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007LL
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int arr[MAX],check[MAX],ans;
int main()
{
	int n;
	cin>>n;
	int mini=MOD,maxi=-1;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		if(i+1==arr[i])
		{
			check[i]=1;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(i<n-1&&check[i]&&check[i+1])
			ans++,i++;
		else if(check[i])
			ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int N, K;
    scanf("%d %d", &N, &K);
    //1,2,,,k, 2,3,,,,k+1 N-k,,,Nとなるので
    printf("%d", N-K+1);
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
struct dong{
	int t,a;
} ask[maxn];
int p[maxn],ans[maxn];
int i,j,k,l,t,n,m,f,a,b,c,d,e,X;
bool czy;
int get(int x){
	if (czy) return e;
	if (x<=a) return b;
	else if (x>=c) return d;
	else return (x-a)+b;
}
void change(int f,int t){
	if (czy){
		e+=f*t;
		e=max(0,min(X,e));
		return;
	}
	if (f==-1){
		if (d-t<=0){
			czy=1;
			e=0;
			return;
		}
		if (t>=b){
			a+=t-b;
			b=0;
			d-=t;
		}
		else{
			b-=t;
			d-=t;
		}
	}
	else{
		if (b+t>=X){
			czy=1;
			e=X;
			return;
		}
		if (d+t>=X){
			b+=t;
			c-=d+t-X;
			d=X;
		}
		else{
			b+=t;
			d+=t;
		}
	}
}
int main(){
	scanf("%d",&X);
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&p[i]);
	scanf("%d",&m);
	fo(i,1,m) scanf("%d%d",&ask[i].t,&ask[i].a);
	j=0;
	a=0;b=0;c=X;d=X;
	f=-1;
	fo(i,1,n){
		while (j<m&&ask[j+1].t<p[i]){
			j++;
			k=ask[j].a;
			ans[j]=max(0,min(X,get(k)+f*(ask[j].t-p[i-1])));
		}
		change(f,p[i]-p[i-1]);
		f*=-1;
	}
	while (j<m){
		k=ask[++j].a;
		ans[j]=max(0,min(X,get(k)+f*(ask[j].t-p[n])));
	}
	fo(i,1,m) printf("%d\n",ans[i]);
}

Measured memory_bytes: 2688
n=int(input())

t=int(2*n**0.5)
ans = {i for i in range(1,t+1)}

sum=t*(t+1)//2


for i in range(t,0,-1):
    if sum-i >n:
        ans.remove(i)
        sum -= i
    elif sum-i == n:
        ans.remove(i)
        break

for i in ans:
    print(i)


Measured memory_bytes: 9868
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		List<Integer> monsters = new ArrayList<>();
		while (scanner.hasNextInt()) {
			monsters.add(scanner.nextInt());
		}

		Collections.sort(monsters);
		int min = monsters.get(0);

		while (true) {
			int pos = -1;
			for (int i = 1; i < monsters.size(); i++) {
				if (monsters.get(i) % min != 0
						&& monsters.get(i) % min < min) {
					min = monsters.get(i) % min;
					pos = i;
				}
			}
			if (pos != -1) {
				monsters.set(pos, min);
				Collections.sort(monsters);
			} else {
				break;
			}
		}

		System.out.println(min);
	}
}

Measured memory_bytes: 62292
// A - Not
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    int x;
    cin >> x;
    if(x) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  if(N%2==0){
    N/=2;
    for(int i=0;i<N;i++){
      if(S[i]==S[N+i]){
        if(i==N-1){
          cout<<"Yes"<<endl;
        }
      }
      else {
        cout<<"No"<<endl;
        break;
      }
    }
  }
  else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int f[26];

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n;
        cin>>n;
        string a,b,c;
        cin>>a>>b>>c;
        int ans=0;
        for(int i=0;i<n;i++)
        {
                f[a[i]-'a']++;
                f[b[i]-'a']++;
                f[c[i]-'a']++;
                int mx=0;
                for(int j=0;j<26;j++)
                {
                        mx=max(mx,f[j]);
                }
                ans+=3-mx;
                f[a[i]-'a']--;
                f[b[i]-'a']--;
                f[c[i]-'a']--;
        }
        cout<<ans<<"\n";
        return 0;
}
/**

**/


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	x := readFloat64()

	a := float64(100)
	i := 0
	for {
		i++
		a = math.Floor(a * 1.01)
		if a >= x {
			fmt.Println(i)
			return
		}
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1756
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = n; i <= 999; i++) {
            String k = String.valueOf(i);
            if (k.charAt(0) == k.charAt(1) && k.charAt(1) == k.charAt(2)) {
                System.out.println(k);
                break;
            }
        }

    }

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    map<ll,ll> mp;
    ll n,a;
    while(cin>>n){
        mp.clear();
        while(n--){
            cin>>a;
            ++mp[a];
        }
        ll x=0,y=0;
        for(auto i=mp.begin();i!=mp.end();++i){
            a=i->second;
            if(a > 3){
                x=y=i->first;

            }else if(a > 1){
                x=y;
                y=i->first;
            }
        }
        cout<<x*y<<endl;
    }
    return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;

int n;
int cnt = 0;
vector<ll> x, l;
vector<pair<ll, ll>> rob;

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  cin >> n;
  x.assign(n, -1);
  l.assign(n, -1);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> l[i];
    rob.push_back(make_pair(x[i] - l[i], x[i] + l[i]));
  }
  sort(rob.begin(), rob.end(), compare_by_b);
  ll crnt_pos = -100100100100;
  for (int i = 0; i < n; ++i) {
    ll left = rob[i].first;
    ll right = rob[i].second;
    if (crnt_pos <= left) {
      crnt_pos = right;
      cnt += 1;
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3956
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;

int gcd(ll tara,ll tarb){ //最大公約数
    ll am=1;
    while(am){
        am=tara%tarb;
        tara=tarb;
        tarb=am;
    }
    return tara;
}

int lcm(ll tara,ll tarb){ //最小公倍数
    return tara*tarb/gcd(tara,tarb);
}

int main(){
    cin>>a>>b>>c;
    C (c%gcd(a,b)==0 ? "YES":"NO") E;
    
    
    
    
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a,b;
	int sum = 0;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=b;i++)
	{
		int c;
		scanf("%d",&c);
		sum += c;
	}
	printf("%d",sum>a?-1:a-sum);
}

Measured memory_bytes: 1736
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    vector<ll> s(n+1,0);
    REP(i, n) s[i+1] = s[i] + a[i];
    map<ll, ll> nums;
    REP(i, n+1) nums[s[i]]++;

    ll res = 0;
    for(auto it : nums) {
        ll num = it.second;
        res += (num) * (num-1) / 2;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 15104
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    k = II()
    ans = ""
    for i in range(k):
        ans += "ACL"

    print(ans)


main()


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

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

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

using namespace std;

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


void solve()
{
    int A, B, C, D; cin >> A >> B >> C >> D;
    int ans = min(B, D) - max(A, C);
    if(ans < 0) cout << 0 << endl;
    else cout << ans << endl;
}

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

ll f(vector<ll>& l, vector<ll>& p, int n, ll x) {
    if (n == 0)
        return x <= 0 ? 0 : 1;
    if (x - 1 <= l[n-1])
        return f(l, p, n-1, x-1);
    return p[n-1] + 1 + f(l, p, n-1, x-l[n-1]-2);
}

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

    int N; cin >> N;
    ll X; cin >> X;
    vector<ll> l(N), p(N);
    l[0] = p[0] = 1;
    for (int i = 1; i < N; i++) {
        l[i] = l[i-1] * 2 + 3;
        p[i] = p[i-1] * 2 + 1;
    }
    cout << f(l, p, N, X) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);



int main() {
  int n; cin >> n;
  string s,t; cin >> s >> t;
  string ans;
  rep(i,n) {
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;

}

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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll buf = 0;
    rep(i, n) {
        cin >> a[i];
        buf += a[i];
        buf %= MOD;
    }

    ll ans = 0;
    rep(i, n) {
        buf -= a[i];
        buf %= MOD;
        if(buf < 0) buf += MOD;

        ans += a[i] * buf;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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


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

int main(){
  int smallx[5] = {0,1,0,-1,0};
  int smally[5] = {0,0,1,0,-1};
  int middlex[9] = {0,0,0,-1,-1,-1,1,1,1};
  int middley[9] = {0,-1,1,0,-1,1,0,-1,1};
  int largex[13] = {0,2,1,1,1,0,0,0,0,-1,-1,-1,-2};
  int largey[13] = {0,0,1,0,-1,2,1,-1,-2,1,0,-1,0};
  char cc;
  int a,b,c,x,y;
  int max = 0;
  int plot[10][10];
  for(int y=0;y<10;y++){
    for(int x=0;x<10;x++){
      plot[x][y] = 0;
    }
  }
  int paint = 0;
  while(cin>>a>>cc>>b>>cc>>c){
    if (c==1){
      for(int i=0;i<5;i++){
	x = a+smallx[i];
	y = b+smally[i];
	if(0<=x&&0<=y&&x<10&&y<10){
	  if (plot[x][y] == 0)paint++;
	  plot[x][y]++;
	  if(max<plot[x][y])max=plot[x][y];
	}
      }
    }
    if (c==2){
      for(int i=0;i<9;i++){
	x = a+middlex[i];
	y = b+middley[i];
	if(0<=x&&0<=y&&x<10&&y<10){
	  if (plot[x][y] == 0)paint++;
	  plot[x][y]++;
	  if(max<plot[x][y])max=plot[x][y];
	}
      }
    }
    if (c==3){
      for(int i=0;i<13;i++){
	x = a+largex[i];
	y = b+largey[i];
	if(0<=x&&0<=y&&x<10&&y<10){
	  if (plot[x][y] == 0)paint++;
	  plot[x][y]++;
	  if(max<plot[x][y])max=plot[x][y];
	}
      }
    }
  }
  cout<<100-paint<<endl<<max<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<15)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int MAX_N=200005;

vector<int> a,ans;
vector<int> to[MAX_N];
int dp[MAX_N];

void dfs(int v,int p=-1){
    int i=lower_bound(dp,dp+MAX_N,a[v])-dp;
    int old=dp[i];
    dp[i]=a[v];
    ans[v]=i;
    if(p!=-1)ans[v]=max(ans[v],ans[p]);
    for(int u:to[v]){
        if(u==p)continue;
        dfs(u,v);
    }
    dp[i]=old;
}

int main(){
    int n;
    cin>>n;
    a=ans=vector<int>(n);
    rep(i,n) cin>>a[i];
    rep(i,n-1){
        int u,v;
        cin>>u>>v;
        --u;--v;
        to[v].pb(u);
        to[u].pb(v);
    }
    rep(i,MAX_N)dp[i]=1001001001;
    dp[0]=-1001001001;
    dfs(0);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 30832
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>a;
	for(i=1;i<=a;i++){
		b=i*108/100;
		if(a==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

int a[100010];
int main(){
	int n,s;
	scanf("%d%d",&n,&s);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int ans=1e6;
	int r=0,sum=0;
	for(int l=0;l<n;l++){
		while(r<n&&sum<s)sum+=a[r++];
		if(sum>=s)ans=min(ans,r-l);
		sum-=a[l];
	}
	printf("%d\n",ans==1e6?0:ans);
}



Measured memory_bytes: 2244
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N,M;
    cin >> N >> M;

    ll ans = 0;
    if(2*N <= M){
        M -= 2*N;
        ans += N;
        ans += M/4;
    }else{
        ans = M/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}

const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){ans *=(n+1-j); ans /= j; ans %= MOD;} }return ans;}
template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;}

int dfs(int start, bool checked[], vector<vector<int>> &v, int d){
  if(checked[start]) return -1;
  checked[start] = true;
  int depth = d;
  for(auto ele: v[start]){
    if (checked[ele] == false) {
      depth += dfs(ele, checked, v, 1);
    }
  }
  return depth;
}

void solve(){
  int n, m; cin >> n >> m;
  set<pair<int,int>> info;
  rep(i, m) {
    pair<int,int> p;
    int a, b; cin >> a >> b;
    if(a > b) swap(a, b);
    p = make_pair(a, b);
    info.insert(p);
  }
  vector<vector<int>> vv(n + 1);
  for(auto p : info){
    vv[p.first].push_back(p.second);
    vv[p.second].push_back(p.first);
    // cout << p.first << " " << p.second << endl;
  }
  bool checked[n + 1];
  rep(i, n) checked[i + 1] = false;
  int ans = -2;
  for(int i = 1; i <= n; ++i) {
    ans = max(ans, dfs(i, checked, vv, 1));
  }
  cout << ans << endl;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 32984
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;

	vector<int> t2;
	for (int i = 0;i < n;i++) {
		if (t[i] == 'r') t2.push_back(2);
		if (t[i] == 's') t2.push_back(0);
		if (t[i] == 'p') t2.push_back(1);
	}
	int sc[3] = { r, s, p };

	int score = 0;
	for (int i = 0;i < n;i++) {
		score += sc[t2[i]];
	}

	for (int i = 0;i < n - k;i++) {
		if (t2[i] == t2[i + k]) {
			score -= sc[t2[i]];
			t2[i + k] = -1;
		}
	}
	cout << score;
	return 0;
}

Measured memory_bytes: 1020
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		//private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			Dictionary<int, long[]> count = new Dictionary<int, long[]>();
			for (int i = 0; i < n; i++) {
				if (!count.ContainsKey(a[i])) {
					count.Add(a[i], new long[3]);
				}
				count[a[i]][0]++;
			}
			long sum = 0;
			foreach (var item in count) {
				item.Value[1] = Combination((int)item.Value[0], 2);
				item.Value[2] = Combination((int)item.Value[0] - 1, 2);
				sum += item.Value[1];
			}
			for (int i = 0; i < n; i++) {
				long ans = sum - count[a[i]][1] + count[a[i]][2];
				Console.WriteLine(ans);
			}


			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}

		#region 場合の数（rが一桁程度）
		static long Combination(int n, int r)
		{
			if (n < r) { return 0; }
			r = Math.Min(r, n - r);
			long ans = 1;
			for (int i = n; i > n-r; i--) {
				ans *= i;
			}
			for (int i = 2; i <= r; i++) {
				ans /= i;
			}
			return ans;
		}
		#endregion

	}
}

Measured memory_bytes: 49852
n = int(input())
p = list(map(int, input().split()))

count = 0

for i in range(n - 2):
    if p[i] < p[i + 1] < p[i + 2]:
        count = count + 1
    elif p[i + 2] < p[i + 1] < p[i]:
        count = count + 1

print(count)

Measured memory_bytes: 3060
D=*0..N=gets.to_i;c=2,i=1;$<.map{|l|a,b=l.split.map &:to_i;D[a],D[b]=D[b],D[a];i!=a&&i!=b||i=a+b-i;c<<D[i-1]<<D[i+1]};p (c-[0,N+1]|$*).size

Measured memory_bytes: 7316
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var (
	n int
	A []int
)

func main() {
	fmt.Println(answer(os.Stdin))
}

func solve(i, m int) bool {
	if m == 0 {
		return true
	}
	if i >= n {
		return false
	}
	return solve(i+1, m) || solve(i+1, m-A[i])
}

func answer(r io.Reader) string {
	sc := bufio.NewScanner(r)
	var buf bytes.Buffer
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	sc.Scan()
	A = make([]int, n)
	ss := strings.Fields(sc.Text())
	for i := 0; i < n; i++ {
		A[i], _ = strconv.Atoi(ss[i])
	}
	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	ss = strings.Fields(sc.Text())
	for j := 0; j < m; j++ {
		M, _ := strconv.Atoi(ss[j])
		if solve(0, M) {
			buf.WriteString("yes\n")
			continue
		}
		buf.WriteString("no\n")
	}
	return strings.TrimRight(buf.String(), "\n")
}



Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define iton for(long long i=0;i<n;i++)
#define jtom for(long long j=0;j<m;j++)
#define itok for(long long i=0;i<k;i++)
void solve()
{
    int n;
    cin>>n;
    vector<double> v(n);
    iton
    {
        cin>>v[i];
    }
    double dp[n+1][n+1];
    dp[0][0] = 1.000000000;
    for(int i=1;i<=n;i++)
    {
        dp[0][i] = 0.000000000;
    }
    for(int i=1;i<=n;i++)
    {
        dp[i][0] = dp[i-1][0] * (1.0-v[i-1]) ;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j] = dp[i-1][j-1] * v[i-1] + dp[i-1][j] * (1.0-v[i-1]);
        }
    }
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=n;j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    long k = n/2 +1;
    double sum=0.000000000;
    for(int i=0;i<=n;i++)
    {   
        if(i>=k)
        sum += dp[n][i];
    }

    cout<<fixed<<setprecision(10)<<sum;
    // cout<<sum;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    solve();
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n, k; cin >> n >> k;
    --k;
    string s; cin >> s;
    s[k] += 32;
    cout << s << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define YES "Yes"
#define NO "No"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
template<class T> inline bool chmax(int a, int b, T c, T d) { return c > d ? a : b; }
template<class T> inline bool chmin(int a, int b, T c, T d) { return c > d ? a : b; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<ut, VI, greater<LL> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W, R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
LL A[SIZE];
LL solve() {
	cin >> N;
	LL mn = INF, mx = 0;
	REP(i, N) {
		LL x;
		cin >> x;
		A[x]++;
		MN(mn, x);
		MX(mx, x);
	}
	if (mx - mn > 1) return 0;
	if (A[mx] == 1) return 0;
	if (mx == mn) {
		if (mx == N - 1 or mx <= N / 2) return 1;
		return 0;
	}
	if (A[mn] <= mn and mn  <= A[mn] + A[mx] / 2 - 1) return 1;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(0);
	YESNO;


	//cin >> N;
	return 0;

}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod


int n, m;
vector<vector<int>> g(1000000 + 6);

int ord[1000000 + 6], low[1000000 + 6];
bool visited[1000000 + 6];

vector<pair<int, int>> Bridges;
vector<int> Points;

void dfs(int now, int par, int &cnt) {
    visited[now] = true;
    ord[now] = cnt++;
    low[now] = ord[now];
    bool check = false;
    int outdeg = 0;
    for (auto nx : g[now]) {
        if (nx == par) continue;
        if (!visited[nx]) {
            outdeg++;
            dfs(nx, now, cnt);
            low[now] = min(low[now], low[nx]);
            //???????????????
            if (ord[now] < low[nx]) {
                Bridges.push_back({min(now, nx), max(now, nx)});
            }
            //??¢??????????????????
            if (par != -1 && !check && ord[now] <= low[nx]) {
                check = true;
                Points.push_back(now);
            }
        }
        else {
            low[now] = min(low[now], ord[nx]);
        }
    }
    //???????????????????????\?????¢????????¨???????????????
    if (par == -1 && outdeg >= 2) {
        Points.push_back(now);
    }
    return;
}

void lowlink (int n, vector<vector<int>>& g) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            dfs(i, -1, cnt);
        }
    }
    sort(all(Bridges));
    sort(all(Points));
    return;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    lowlink(n, g);
    rep(i, Bridges.size()) {
        cout << Bridges[i].fi << " " << Bridges[i].se << endl;
    }
    /*
    rep(i, Points.size()) {
        cout << Points[i] << endl;
    }
    */
}

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

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

	if (N < 105) {
		cout << "0" << endl;
	}
	else if (N < 135) {
		cout << "1" << endl;
	}
	else if (N < 165) {
		cout << "2" << endl;
	}
	else if (N < 189) {
		cout << "3" << endl;
	}
	else if (N < 195) {
		cout << "4" << endl;
	}
	else {
		cout << "5" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    if a[i] < b[i]:
        ans += min(b[i], a[i]+a[i+1])
        a[i+1] -= min(a[i+1], b[i]-a[i])
    else:
        ans += b[i]
print(ans)


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

signed main(){
    
    cin >> H >> W >> h >> w;
    if(H%h == 0 && W%w == 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;


    if(W%w != 0){
        rep(i,H){
            rep(j,W){
                int a = 0;
                if(j%w == 0)a = 1000;
                else if(j%w == w-1)a = -1001;
                cout << a << " ";
            }
            cout << endl;
        }
    }else{
        rep(i,H){
            rep(j,W){
                int a = 0;
                if(i%h == 0)a = 1000;
                else if(i%h == h-1)a = -1001;
                cout << a << " ";
            }
            cout << endl;
        }
    }
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://agc016.contest.atcoder.jp/tasks/agc016_c

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int K = cin.nextint;

        long ans = 0;
        //k のmodを全探索
        for (int i = 0; i < K; i++)
        {
            if (2 * (K - i) % K == 0)
            {
                if (i == 0)
                {
                    ans += (long)(N / K) * (N / K) * (N / K);
                }
                else
                {
                    int P = N / K;
                    int cnt = P;
                    int cnt2 = P;
                    if (K * P + i <= N) cnt++;
                    if (K * P + (K - i) <= N) cnt2++;

                    //WriteLine(i + " " + cnt + " " + cnt2);
                    ans += (long)cnt * cnt2 * cnt2;
                }
            }
        }

        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

using namespace std;

int main(void) {
    const int k = 10000;
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    if (n % a == 0 && m % b == 0) return cout << "No" << endl, 0;
    cout << "Yes" << endl;
    if (n % a != 0) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (i % a == 0) cout << k * (a - 1) - 1 << ' ';
                else cout << -k << ' ';
            }
            cout << '\n';
        }
    }
    else {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (j % b == 0) cout << k * (b - 1) - 1 << ' ';
                else cout << -k << ' ';
            }
            cout << '\n';
        }
    }
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll> > vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge> > Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    ll N;
    cin>>N;
    ll tmp;
    ll flg=0;
    REP(i,N){
        cin>>tmp;
        if(tmp%2!=0)flg=1;
        }
    if (flg)
    cout<<"first" <<endl;
    else
    cout<<"second"<<endl;
    
}


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

using namespace std;

typedef long long int lli;

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

    int n;
    lli a, b;
    priority_queue<pair<lli, lli>> event;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a >> b;
        event.push(make_pair(-b, a));
    }

    lli time = 0, task = 0;
    while (!event.empty()) {
        lli bb = -event.top().first, aa = event.top().second;
        event.pop();

        task += (bb-time) - aa;
        time = bb;

        // cout << task << " " << time << endl;

        if (task < 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 6384
#include <algorithm>
#include <iostream>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int n, q, k;
  string s;
  cin >> n >> s >> q;
  while (q--) {
    cin >> k;
    ll D = 0, M = 0, DM = 0, ans = 0;
    rep(i, 0, n) {
      if (s[i] == 'D')
        ++D;
      else if (s[i] == 'M')
        DM += D, ++M;
      else if (s[i] == 'C')
        ans += DM;
      if (i - k + 1 >= 0) {
        if (s[i - k + 1] == 'D') {
          --D;
          DM -= M;
        } else if (s[i - k + 1] == 'M')
          --M;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 5212
H, W = map(int, input().split())

matrix = [["#"]*(W+2) for i in range(H+2)]

for i in range(1, H+1):
    row = list(input())
    for j in range(1, W+1):
        matrix[i][j] = row[j-1]

for row in matrix:
    print("".join(row))


Measured memory_bytes: 3060