akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define PB push_back
#define F first
#define S second
#define B begin()
#define E end()
#define MP make_pair
using namespace std;
typedef pair<int,int>P;
typedef vector<int>V;
typedef vector<P>VP;
int dp[12][2001];
V book[11];
VP bk[11];
int main(void){
	int n,m;
	int a,b;
	int i,j,k;
	int sum,cnt;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a>>b;
		book[b].PB(a);
	}
	for(i=0;i<=10;i++){
		if(book[i].size()!=0){
			sort(book[i].B,book[i].E,greater<int>());
		}
	}
 	/* for(i=0;i<=10;i++){
		if(book[i].size()!=0){
			for(j=0;j<book[i].size();j++){
				cout<<book[i][j]<<endl;
			}
		}
	}  */
	for(i=0;i<=10;i++){
		sum=0;
		if(book[i].size()!=0){
			for(j=0;j<book[i].size();j++){
				sum+=book[i][j];
				if(j==0)	bk[i].PB(MP(book[i][j],1));
				else		bk[i].PB(MP(sum+j*(j+1),j+1));
			}
		}
		bk[i].PB(MP(0,0));
	}
	/* for(i=0;i<=10;i++){
		cout<<"I="<<i<<endl;
		for(j=0;j<bk[i].size();j++){
				cout<<bk[i][j].F<<" "<<bk[i][j].S<<endl;
				cout<<"J="<<j<<endl;
		}
	} */
	for(i=0;i<=10;i++){
		for(j=0;j<=m;j++){
			dp[i][j]=-1;
		}
	}
	//cout<<"JOI"<<endl;
	dp[1][0]=0;
	for(i=1;i<=10;i++){
		//cout<<"I="<<i<<endl;
		for(j=0;j<=m;j++){
			/* cout<<"J="<<j<<endl;
			cout<<bk[i].size()<<endl; */
			for(k=0;k<bk[i].size();k++){
				//cout<<"K="<<k<<endl;
				if(j+bk[i][k].S<=m&&dp[i][j]!=-1){
					dp[i+1][j+bk[i][k].S]=max(dp[i+1][j+bk[i][k].S],dp[i][j]+bk[i][k].F);
				}
			}
		}
	}
	/* for(i=1;i<=10;i++){
		for(j=0;j<=m;j++){
			cout<<dp[i][j];
		}
		cout<<endl;
	}  */
	int MAX=-1;
	for(i=1;i<=m;i++){
		MAX=max(MAX,dp[11][i]);
	}
	cout<<MAX<<endl;
	return 0;
}
	


Measured memory_bytes: 3288
import java.util.Scanner;

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

		long d = a;
		a = a-c;
		if(a<0) { a = 0; }
		c = c-d;
		if(c>0) { b = b-c; }
		if(b<0) { b = 0; }
		System.out.println(a+" "+b);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<pair<ll,ll>> vep;
const ll mod=1000000007;
const ll INF=1e15;
const int BIG=1e7;

int main(){
    int N; cin>>N;
    cout<<(N-1)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;
int a[100010];
int b[100010];
signed main(){
  int n;cin>>n;
  rep(i,n+1)cin>>a[i];
  rep(i,n)cin>>b[i];
  int ans=0;
  rep(i,n){
    if(b[i]<=a[i])a[i]-=b[i],ans+=b[i];
    else if(b[i]<=a[i]+a[i+1])a[i+1]-=(b[i]-a[i]),a[i]=0,ans+=b[i];
    else ans+=a[i]+a[i+1],a[i]=0,a[i+1]=0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5168
#include<cstdio>

const double eps=1e-7;

struct Vector
{
	int x,y;
	Vector(){};
	Vector(int x,int y):x(x),y(y){};
	void read()
	{
		scanf("%d %d",&this->x,&this->y);
		return;
	}
};

inline Vector operator + (const Vector &fi,const Vector &se)
{
	return Vector(fi.x+se.x,fi.y+se.y);
}

inline Vector operator - (const Vector &fi,const Vector &se)
{
	return Vector(fi.x-se.x,fi.y-se.y);
}

inline int operator ^ (const Vector &fi,const Vector &se)
{
	return fi.x*se.y-fi.y*se.x;
}

typedef Vector Point;

int n;
Point p[20];
bool use[20];

Vector e[20];
int cnt=0;
int ans=0;


void dfs(int w)
{
	if(w>n)
	{
		int nowans=0;
		for(int i=1;i<=cnt;i++)
		{
			for(int j=i+1;j<=cnt;j++)
			{
				if((e[i]^e[j])==0)
				{
					nowans++;
				}
			}
		}
		if(nowans>ans)
			ans=nowans;
		return;
	}
	if(use[w])
	{
		dfs(w+1);
		return;
	}
	use[w]=1;
	for(int i=w+1;i<=n;i++)
	{
		if(!use[i])
		{
			use[i]=1;
			cnt++;
			e[cnt]=p[i]-p[w];
			dfs(w+1);
			cnt--;
			use[i]=0;
		}
	}
	use[w]=0;
}


int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		p[i].read();
	}
	dfs(1);
	printf("%d\n",ans);
}



Measured memory_bytes: 2744
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
 
using namespace std;

//(x,y)???????????????top
map<pair<int,int>,int> table;

//(x,y)?????????
map<pair<int,int>,int> h;

//        0 1 2 3 4 5
int dx[]={0,1,0,0,-1,0};
int dy[]={0,0,1,-1,0,0};

// f2[t][u]...f[0]=t,f[1]=u?????¨??????f[2]
// top,front(left)->front(right)
int f2[7][7]={
//front1,2,3,4,5,6
	{0,0,0,0,0,0,0},
	{0,0,3,5,2,4,0}, //top=1
	{0,4,0,1,6,0,3}, //top=2
	{0,2,6,0,0,1,5}, //top=3
	{0,5,1,0,0,6,2}, //top=4
	{0,3,0,6,1,0,4}, //top=5
	{0,0,4,2,5,3,0} //top=6
};

//f[0]:top
//f[1]:front(left)
//f[2]:front(right)
//f[5]+f[0]=f[4]+f[1]=f[3]+f[2]=7
class Dice
{
public:
	vector<int> f;
	Dice(int a,int b,int c){
		f.resize(6);
		f[0]=a,f[1]=b,f[2]=c;
		f[3]=7-f[2],f[4]=7-f[1],f[5]=7-f[0];
	}
	
	void rotX(int num){
		for(int i=0;i<num;i++){
			int tmp=f[0];
			f[0]=f[1];
			f[1]=f[5];
			f[5]=f[4];
			f[4]=tmp;
		}
	}
	
	void rotY(int num){
		for(int i=0;i<num;i++){
			int tmp=f[0];
			f[0]=f[3];
			f[3]=f[5];
			f[5]=f[2];
			f[2]=tmp;
		}
	}	
};




void update(Dice dice,int x,int y)
{

	int pos6,pos5,pos4;
	bool rolled=false;
	for(int i=0;i<6;i++){
		if(dice.f[i]==6) pos6=i;
		if(dice.f[i]==5) pos5=i;
		if(dice.f[i]==4) pos4=i;
	}
	
	if(pos6!=0 && pos6!=5){
		int nx=x+dx[pos6],ny=y+dy[pos6];

		if(h[make_pair(y,x)]>h[make_pair(ny,nx)]){
			if(pos6==1) dice.rotX(3);
			if(pos6==2) dice.rotY(1);
			if(pos6==3) dice.rotY(3);
			if(pos6==4) dice.rotX(1);
			update(dice,nx,ny);
			rolled=true;
		}
	}
	if(rolled) return ;

	if(pos5!=0 && pos5!=5){
		int nx=x+dx[pos5],ny=y+dy[pos5];

		if(h[make_pair(y,x)]>h[make_pair(ny,nx)]){
			if(pos5==1) dice.rotX(3);
			if(pos5==2) dice.rotY(1);
			if(pos5==3) dice.rotY(3);
			if(pos5==4) dice.rotX(1);
			update(dice,nx,ny);
			rolled=true;
		}
	}
	if(rolled) return ;
	
	if(pos4!=0 && pos4!=5){
		int nx=x+dx[pos4],ny=y+dy[pos4];

		if(h[make_pair(y,x)]>h[make_pair(ny,nx)]){
			if(pos4==1) dice.rotX(3);
			if(pos4==2) dice.rotY(1);
			if(pos4==3) dice.rotY(3);
			if(pos4==4) dice.rotX(1);
			update(dice,nx,ny);
			rolled=true;
		}
	}
	if(rolled) return ;
	
	h[make_pair(y,x)]++;
	table[make_pair(y,x)]=dice.f[0];
	
}



int main()
{
	long long n;
	while(cin>>n,n){
		table.clear();
		h.clear();

		for(int i=0;i<n;i++){
			int top,front;
			cin>>top>>front;
			Dice dice(top,front,f2[top][front]);
			update(dice,0,0);

		}


		vector<int> ans(6,0);
		for(auto it=table.begin();it!=table.end();it++){
			ans[(it->second)-1]++;
		}
		for(int i=0;i<5;i++) cout<<ans[i]<<" ";
		cout<<ans[5]<<endl;


	}

	

	return 0;
}

Measured memory_bytes: 1220
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
  int i;
  int S,W;
  long cnt = 0;
  scanf("%d %d", &S, &W);
  if (S <= W) {
    printf("unsafe\n");
        } else {
          printf("safe\n");
        }
  return 0;
}


Measured memory_bytes: 2088
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main () {
	SpeedForce;
	double r;
	cin >> r;
	cout << fixed << setprecision(10) << 2 * r * pi << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 17880
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

type observatory struct {
	Height int
	Ways   []int
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	M := sc.nextInt()
	O := make([]observatory, N+1)
	for i := 1; i <= N; i++ {
		O[i].Height = sc.nextInt()
	}
	for i := 0; i < M; i++ {
		a := sc.nextInt()
		b := sc.nextInt()
		O[a].Ways = append(O[a].Ways, b)
		O[b].Ways = append(O[b].Ways, a)
	}

	sum := 0
	for i, o := range O {
		if i == 0 {
			continue
		}
		highest := true
		for i := 0; i < len(o.Ways); i++ {
			j := o.Ways[i]
			if o.Height <= O[j].Height {
				highest = false
				break
			}
		}

		if highest {
			sum++
		}
	}

	fmt.Println(sum)

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 12516
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  vector<int> a(7,0);
  rep(i,7){
    cin >> a[i];
  }

  int aI = a[0];
  int aO = a[1];
  int aJ = a[3];
  int aL = a[4];

  ll ret1 = aO, ret2 = aO;
  {
    ll mn = min(aI, min(aJ, aL));
    if(mn > 0) mn = 1;
    ret1 += 3*mn;
    ret1 += 2*((aI-mn)/2);
    ret1 += 2*((aJ-mn)/2);
    ret1 += 2*((aL-mn)/2);
  }
  {
    ret2 += 2*((aI)/2);
    ret2 += 2*((aJ)/2);
    ret2 += 2*((aL)/2);    
  }
  cout << max(ret1,ret2) << endl;
  
  return 0;
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//The Enemy of My Enemy is My Friend
public class Main{

	Map<String, Integer> ref;
	int ID;
	int reg(String s){
		if(ref.containsKey(s))return ref.get(s);
		ref.put(s, ID);
		return ID++;
	}
	
	int N, res;
	int[] sum, B;
	long[] adj;
	
	void f(int k, int score, long mask){
		res = Math.max(res, score);
		if(k==N)return;
		if(score+sum[k]<=res)return;
		if(((mask>>k)&1)>0){
			f(k+1, score, mask); return;
		}
		f(k+1, score+B[k], mask|adj[k]);
		f(k+1, score, mask);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			N = sc.nextInt();
			if(N==0)break;
			ref = new HashMap<String, Integer>();
			ID = 0;
			adj = new long[N];
			B = new int[N];
			for(int i=0;i<N;i++){
				int id = reg(sc.next());
				B[id] = sc.nextInt();
				int m = sc.nextInt();
				while(m--!=0)adj[id]+=1L<<reg(sc.next());
			}
			sum = new int[N+1];
			for(int i=N-1;i>=0;i--)sum[i]=sum[i+1]+B[i];
			res = 0;
			f(1, B[0], adj[0]);
			System.out.println(res);
		}
	}

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

Measured memory_bytes: 12000
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut tot: i64 = 0;
    let mut a = a;
    for i in 1..n {
        let r = max(0, -a[i] + a[i - 1]);
        tot += r;
        a[i] += r;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2676
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
signed main() {
	int ans = 0;
	string s;
	cin >> s;
	int cnt[26];
	for (int l = 0; l < 26; l++)cnt[l] = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt[s[i] - 'a']++;
	}
	for (int l = 0; l < 26; l++) {
		if (cnt[l] > 1)ans++;
	}
	if (ans)puts("no");
	else puts("yes");
	ll
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100],cnt[100],m,ans;
int main(){
  int n; cin>>n;
  ll s=0,x;
  for (int i=1; i<=n; ++i)
    cin>>a[i],s+=a[i];
  if (s>n*(n-1)){
    ans=x=s-n*(n-1);
    for (int i=1; i<=n; ++i)
      a[i]+=x;
    for (int i=1; i<=n; ++i){
      x-=a[i]/(n+1);
      a[i]%=(n+1);
    }
    ans-=x;
    for (int i=1; i<=n; ++i)
      a[i]-=x;
  }
  int flag=1;
  while(flag){
    m=flag=0;
    for (int i=1; i<=n; ++i)
      cnt[i]=a[i]/n,m+=cnt[i];
    for (int i=1; i<=n; ++i){
      a[i]-=cnt[i]*(n+1)-m;
      if (a[i]>=n) flag=1;
    }
    ans+=m;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;


bool prime(int n){
  for (int i = 2; i < (int)(sqrt(n) + 1); i++)
    if (n % i == 0)
      return false;
  return true;
}

int filter(vector<int> primes, int n){
  int result = 0;
  for (int i = 0; i < primes.size(); i++){
    if (primes[i] < n - 1)
      break;
    result++;
  }
  return result;
}

int main(){
  int n;
  cin >> n;
  int m = 2;
  vector<int> primes;
  while (m <= n / 2){
    if (prime(m)){
      int count = 0, tmp = n / m;
      while (tmp > 0){
        count += tmp;
        tmp /= m;
      }
      primes.push_back(count);
    }
    m++;
  }
  cout << filter(primes, 75) + filter(primes, 25) * (filter(primes, 3) - 1)
    + filter(primes, 15) * (filter(primes, 5) - 1)
    + filter(primes, 5) * (filter(primes, 5) - 1) * (filter(primes, 3) - 2) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val ans = solve(N)
    println(ans)
}

// 割り切れる場合
// 切り上げる場合
// 切り捨てる場合
fun solve(N: Int): String {
    val taxRate = 1.08
    val taxRate2 = (1.08 * 100).toInt()
    val N2 = N * 100

    val base = N / taxRate

    val floorTax = floor(base)
    val ceilTax = ceil(base)

    val floorFloor = floor(floorTax * taxRate).toInt()
    val ceilFloor = floor(ceilTax * taxRate).toInt()

    return when {
        N2 % taxRate2 == 0 -> {
            (N2 / taxRate2).toString()
        }
        floorFloor == N -> {
            floorTax.toInt().toString()
        }
        ceilFloor == N -> {
            ceilTax.toInt().toString()
        }
        else -> {
            ":("
        }
    }
}

fun floor(target: Double): Double {
    return Math.floor(target)
}

fun ceil(target: Double): Double {
    return Math.ceil(target)
}


Measured memory_bytes: 33728
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){

    // Seiranchan!
     int S;
     cin >> S;
     int A;
     A = S/100;
     int T = A*100+A*10+A;

     if(T>=S){
         cout << T << endl;
     }else{
         A++;
         T = A*100+A*10+A;
         cout << T << endl;
     }
}



Measured memory_bytes: 256
let () =
  let w, h, x, y, r = Scanf.scanf "%d %d %d %d %d\n" (fun w h x y r -> w, h, x, y, r) in
  (if 0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h then "Yes" else "No")
  |> print_endline

Measured memory_bytes: 2312
# -*- coding: utf-8 -*-
def abs(n):
    if n < 0:
        return -n
    else:
        return n

def min(a, b):
    if a < b:
        return a
    else:
        return b

def abc160d(n, x_in, y_in):
    d_arr = [0 for _ in range(n-1)]
    x = x_in - 1
    y = y_in - 1
    for a in range(0,n):
        for tgt in range(a+1,n):
            d_normal = tgt - a
            d_min = d_normal - 1
            if tgt < x or y < a:
                pass
            else:
                d_short = abs(x-a) + 1 + abs(y-tgt)
                d_min = min(d_normal, d_short) - 1

            d_arr[d_min] += 1

    return d_arr    

###
# main
if(__name__ == '__main__'):
    # input
    n, x, y = map(int, input().split(" "))
    
    ans = abc160d(n, x, y)
    
    # output
    for a in ans:
        print(a)
# else:
    # do nothing


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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int

ll t , n, cons = 1e18;

signed main()
{
    FAST;
    ll a, b;
    cin >> a;
    string str;
    cin >> str;
    b = int(str[0] - 48);
    b *= 10;
    b += int(str[2] - 48);
    b *= 10;
    b += int(str[3] - 48);
    ll ans = (a * b) / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = INPUT()
    print('x' * len(S))


if __name__ == '__main__':
    main()


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

a = [list(map(int,input().split(" "))) for i in range(n)]

b = [list(map(int,input().split(" "))) for j in range(m)]

for i in range(n):
    for j in range(l):
        c = 0
        for k in range(m):
            c += a[i][k]*b[k][j]
        print(c,end="")
        if j != l-1:
            print("",end=" ")
    print()

Measured memory_bytes: 8700
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  string s;
  cin >> s;

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

  if (s == "abc")
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7 ; 
int main() 
{ 
    int s ;
    cin >> s ; 
    vector<int> a  ; 
    for(int i = 3 ; i <= s ; ++i) 
        a.push_back(i) ; 
    vector<long long> dp(s+1) ; 
    dp[0]= 1 ; 
    for(int i=1 ; i <= s ; ++i) {
        for(int j = 0 ; j < a.size() ; ++j) {
            if(i >= a[j]) {
                dp[i] += dp[i-a[j]] ; 
                dp[i] %= mod ; 
            }
        }
    }
    cout << dp[s] ; 
    

    return 0; 
} 


Measured memory_bytes: 3636
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

int a,b,c;
cin>>a>>b>>c;
int n=a-b;

cout<<max(c-n,0)<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<cstdio> 
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=100100,M=N*4;
ll tr[M],a[N],b[N],s[N],n,K,i,j,k,L[N],R[N],v[M],m,f[N],ans;
void change(ll x,ll l,ll r,ll i,ll j,ll v){
    if (i>j) return ;
    if (l==i&&j==r){
        tr[x]=v;
        return ;
    }
    if (tr[x]) tr[x*2]=tr[x*2+1]=tr[x],tr[x]=0;
    ll m=(l+r)/2;
    if (m>=j) change(x*2,l,m,i,j,v);
    else if (m<i) change(x*2+1,m+1,r,i,j,v);
    else change(x*2,l,m,i,m,v),change(x*2+1,m+1,r,m+1,j,v);
}
ll get(ll x,ll l,ll r,ll p)
{
    if (l==r) return tr[x];
    if (tr[x]) tr[x*2]=tr[x*2+1]=tr[x],tr[x]=0;
    ll m=(l+r)/2;
    if (m>=p) return get(x*2,l,m,p);else return get(x*2+1,m+1,r,p);
}
ll calc(ll x)
{
    ll y=get(1,1,m,x);
    if (!y) return 0;
    return f[y]+(v[L[y]]-v[x]+K)%K;
}
int main()
{
    //freopen("1.out","w",stdout);
    scanf("%lld %lld\n",&n,&K);
    for(i=1;i<=n;i++)
    {
        scanf("%lld %lld",a+i,b+i);
        s[i]=s[i-1]+a[i];
        if (b[i]==1&&2*a[i]>K)
        {
            printf("-1\n");
            return 0;
        }
    }
    for(i=1;i<=n;i++)
        if (b[i]==1)
        {
            L[i]=((-2*s[i])%K+K)%K;
            R[i]=((-2*s[i-1])%K+K)%K;
            swap(L[i],R[i]);
        }else L[i]=0,R[i]=K-1;
    
    for(i=1;i<=n;i++) v[++m]=L[i],v[++m]=R[i];
    sort(v+1,v+m+1);
    m=unique(v+1,v+m+1)-v-1;
    for(i=n;i;i--)
    {
        L[i]=lower_bound(v+1,v+m+1,L[i])-v;
        R[i]=lower_bound(v+1,v+m+1,R[i])-v;
        f[i]=calc(L[i]);
        if (L[i]>R[i]) 
            change(1,1,m,R[i]+1,L[i]-1,i);
        else change(1,1,m,1,L[i]-1,i),change(1,1,m,R[i]+1,m,i);
    }
    ans=f[1];
    for(i=1;i<=m;i++)
        ans=min(ans,calc(i));
    printf("%lld\n",s[n]*2+ans);
}

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

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

int main()
{
    ll i,j;
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    double kd = k;
    double dd = d;
    double xd = x;
    if(kd*dd <= 1e18){
        if(x >= k*d){
            cout << x - k*d << endl;
            return 0;
        }
    }
    ll tmp = x/d;
    x %= d;
    if((k - tmp)%2){
        cout << d - x << endl;
    }else{
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

# A+Bの上位K個
tmp = []
for a in A:
    for b in B:
        tmp.append(a + b)
tmp.sort(reverse=True)
tmp = tmp[:K]

ans = []
for ab in tmp:
    for c in C:
        ans.append(ab + c)
ans.sort(reverse=True)

for i in range(K):
    print(ans[i])


Measured memory_bytes: 217760
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define FOR(variable,start,end) for(int variable = start; variable < end; ++variable)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    
    char c;
    cin >> c;
    if(isupper(c)){
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
# coding: utf-8
import sys


def main(argv=sys.argv):

  input_ = input()
  
  if input_.count('5') == 2 and \
     input_.count('7') == 1:
    print('YES')
  else:
    print('NO')

  return 0


if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.S<b.S)
    return true;
    return false;
}
void solve()
{
    int n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<k;i++)
    cout<<s<<" ";
    s=(s==1)?2:s-1;
    for(int i=0;i<n-k;i++)
    cout<<s<<" ";
    cout<<endl;
}
int main()
{
    solve();
    return 0;
}


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

int gcd(int x, int y) {
    if (x % y == 0) {
        return y;
    }

    else {
        return gcd(y, x % y);
    }
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int D = gcd(A, B);
  if (C % D == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
#include<iomanip>
using namespace std;
int main() {
	int a[2],b[2];
	scanf("%d%d%d%d",&a[0],&a[1],&b[0],&b[1]);
	int i,j;
	for(i=0;i<b[1]-a[1];i++){
		printf("U");
	}
	for(i=0;i<b[0]-a[0];i++){
		printf("R");
	}
	for(i=0;i<b[1]-a[1];i++){
		printf("D");
	}
	for(i=0;i<b[0]-a[0];i++){
		printf("L");
	}
	
	printf("L");
	for(i=0;i<b[1]-a[1]+1;i++){
		printf("U");
	}
	for(i=0;i<b[0]-a[0]+1;i++){
		printf("R");
	}
	printf("DR");
	for(i=0;i<b[1]-a[1]+1;i++){
		printf("D");
	}
	for(i=0;i<b[0]-a[0]+1;i++){
		printf("L");
	}
	printf("U\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];
ll facter[2020202];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
		facter[a[i]]++;
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	rep(i, n) {
		ll target = a[i];
		vector<ll>sosuu;
		facter[a[i]]--;
		for (ll j = 1;j <= sqrt(target) + 1;++j) {
			if (target % j == 0) {
				ll target2 = target / j;
				sosuu.push_back(j);
				sosuu.push_back(target2);
			}
		}
		bool flag = true;
		rep(j, sosuu.size()) {
			if (facter[sosuu[j]]) {
				flag = false;
			}
		}
		if (flag)ans++;
		facter[a[i]]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12524
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII >
#define VLL vector<PLL >
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define FF first
#define SS second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=1e6+10;
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

LL f[MAXN];
string a;

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>t>>n>>m>>a;
	repu(i,0,t-1){
		if(a[i]=='c')cout<<"No\n";
		else if(a[i]=='b'&&ca<m&&ans<n+m)cout<<"Yes\n",ans++,ca++;
		else if(a[i]=='a'&&ans<n+m)cout<<"Yes\n",ans++;
		else cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main(){

    long long N, M;
    cin >> N >> M;

    long long ans;
    if (N >= 3 && M >= 3){
        ans = (N - 2) * (M - 2);
    }else if (N == 2 || M == 2){
        ans = 0;
    }else if(N == 1 && M == 1){
        ans = 1;
    }else{
        ans = N * M - 2;
    }
    
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
 $n--;
 $s = 'abcdefghijklmnopqrstuvwxyz';
 $ans = [];
 while(1){
   $m = $n%26;
   $n = intdiv($n, 26);   
   $ans[] = $s[$m];
   if($n == 0){
     break;
   }
   $n--;
 }

 $ans = array_reverse($ans);

 $start = 0;
 for ($i=$start; $i<count($ans); $i++) {
   echo $ans[$i];
 }

Measured memory_bytes: 16092
l, r = map(int, input().split())
if r - l > 2019 * 2:
    r -= ((r - l - 1) // 2019 - 1) * 2019
ret = 2019
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        ret = min(ret, (i * j) % 2019)
print(ret)

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

int main(){
  int S;
  cin >> S;
  int A , B;
  A = S/100;
  B = S%100;
  if(1<=A && A<=12){
    if(1<=B && B<=12){
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    if(1<=B && B<=12){
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans=0;
  ans+=n/(a+b)*a;
  n%=(a+b);
  ans+=min(n,a);
  cout << ans << endl;
}

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

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

    int a = n % 10;
    if (a == 3)
    {
        cout << "bon" << endl;
    }
    else if (a == 0 || a == 1 || a == 6 || a == 8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }

    return 0;
}

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

int main() {
  int n;
  string s,t;
  cin >> n >> s >> t;
  
  for(int i=0;i<n;i++){
    cout << s.at(i) << t.at(i);
    if( i == n-1) cout << endl;
  }
  
}


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

int main() {
  string s;
  cin >> s;

  int y = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
  int m = (s[5] - '0') * 10 + (s[6] - '0');
  int d = (s[7] - '0') * 10 + (s[8] - '0');

if (y < 2019 || (y == 2019 && m < 4) || (y == 2019 && m == 4 && d < 30))
  cout << "Heisei" << endl;
else
  cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>

using ull = unsigned long long;

int main(){

	int K;
	std::cin >> K;

	std::queue<ull> queue_;

	for( int i{ 1 }; i <= 9; ++i )
		queue_.emplace( i );

	ull cnt_ = K;
	ull ans = 0;
	while( cnt_ > 0 )
	{
		const auto v = queue_.front();
		queue_.pop();
		--cnt_;
		//std::cout << v << ":" << cnt_ << "\n";
		if( cnt_ == 0 )
			ans = v;

		const auto a = v * 10 + v % 10;

		if( a % 10 != 0 )
			queue_.emplace( a - 1 );

		queue_.emplace( a );


		if( a % 10 != 9 )
			queue_.emplace( a + 1 );

	}
	//ans = queue_.front();

	std::cout << ( K <= 9 ? K : ans ) << "\n";

	return 0;
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int n;cin>>n;
  vector<int> v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  int a=0;
  int b=0;
  bool flag=true;
  for(int i=n-1;i>=0;i--){
    if(flag){
      a+=v[i];
      flag=false;
    }
    else{
      b+=v[i];
      flag=true;
    }
  }
  cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int R, C, N;

struct point{
	int r, c, id;
};

int lev(point p){
	if(p.r == 0) return 0;
	if(p.c == C) return 1;
	if(p.r == R) return 2;
	if(p.c == 0) return 3;
	return 4;
}

bool comp(point lhs, point rhs){
	int levl = lev(lhs);
	int levr = lev(rhs);
	if(levl != levr) return levl < levr;

	if(levl == 0) return lhs.c < rhs.c;
	if(levl == 1) return lhs.r < rhs.r;
	if(levl == 2) return lhs.c > rhs.c;
	if(levl == 3) return lhs.r > rhs.r;
}

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


	cin >> R >> C >> N;

	vector<point> v;
	int id = 0;
	rep(i, N){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;

		point p1 = (point){x1, y1, id};
		point p2 = (point){x2, y2, id};
		if(lev(p1) < 4 && lev(p2) < 4){
			v.push_back(p1);
			v.push_back(p2);
			id++;
		}
	}

	if(v.size() == 0){
		cout << "YES" << endl;
		return 0;
	}

	sort(v.begin(), v.end(), comp);

	// rep(i, v.size()) cout << v[i].r << "," << v[i].c << "," << v[i].id << endl;

	stack<int> stc;
	set<int> st;

	for(int i = 0; i < v.size(); i++){
		point p = v[i];
		if(stc.size() == 0){
			stc.push(p.id);
			st.insert(p.id);
			continue;
		}

		if(stc.top() == p.id){
			stc.pop();
			st.erase(p.id);
			continue;
		}

		auto itr = st.find(p.id);
		if(itr == st.end()){
			stc.push(p.id);
			st.insert(p.id);
		}else{
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    ll d[N];
    REP(i, N){
        cin >> d[i];
    }

    ll ans = 0;
    REP(i, N){
        FOR(j, i+1, N-1){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;

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

    double n, m,sum=0,num=0;
    cin >> n >> m;
    vector<double> a(n);
    rep(i, 0, n) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    rep(i, 0, n) {
        if(a.at(i) >= sum / (4 * m))
            ++num;
        if(num >= m) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;

int main(){
	cin>>s;
	cout<<string(s.size(),'x')<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
const int mod=1e9+7;
#define N 2005 
int dp[N],n;
int main(){
	std::cin>>n;
	dp[0]=1;
	rep(i,3,n){
		rep(j,3,i){
			(dp[i]+=dp[i-j])%=mod;
		}
	}
	std::cout<<dp[n]<<'\n';
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n, m, x, y; int num[100000]; int pos[100000] = {}; pos[0] = 1;
	fill(num, num + 100000, 1);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> x >> y; x--; y--;
		if (pos[x] == 1) {
			pos[y] = 1;
			if (num[x] == 1)pos[x] = 0;
		}
		num[y]++; num[x]--;
	}
	int count=0;
	for (int i = 0; i < n; i++) {
		if (pos[i] == 1)count++;
	}
	cout << count << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val aList = readLine()
        ?.split(" ")
        ?.map { it.toLong() }
        ?.toMutableList()
        ?: return

    // 後々の計算を楽にするためfirstとlastに0を加えておく
    // 計算量はO(N)
    aList.add(0, 0)
    aList.add(0)

    // i番目の要素に訪れない場合に料金がどれくらい変わるか、をそれぞれ計算して配列にもつ
    val amountDiffList = mutableListOf<Long>()

    for (i in aList.indices) {
        if (i == 0 || i == aList.lastIndex) {
            continue
        }

        // i-1, i, i+1と移動するときの値段をiあり・なしで計算
        val defaultAmount = Math.abs(aList[i-1] - aList[i]) + Math.abs(aList[i] - aList[i+1])
        val changingAmount = Math.abs(aList[i-1] - aList[i+1])

        amountDiffList += (defaultAmount - changingAmount)
    }

    // すべてのiを回ったときの合計金額も計算する
    var totalAmount = 0L
    for (i in aList.indices) {
        if (i == 0) continue
        totalAmount += Math.abs(aList[i-1] - aList[i])
    }

    // トータルから差を引いたものが、iを訪れなかった場合の合計金額
    for (diff in amountDiffList) {
        println(totalAmount - diff)
    }
}

Measured memory_bytes: 60128
#include <iostream>
using namespace std;
int main()
{
	int A,B,C,D,t;
	cin>>A>>B>>C>>D;
	if(1<=A<=1000
	    &&1<=B<=1000
		&&1<=C<=1000
		&&1<=D<=1000)
	{
		if(A>B)
		t=B;
		else t=A;
		if(C>D)
		t=t+D;
		else t=t+C;
		cout<<t;
	}
    return 0; 
}

Measured memory_bytes: 888
N ,*A  = map(int,open(0).read().split())

L = [0 for i in range(N+1)]
D = [0 for i in range(N)]

for i,a in enumerate(A,1):
  L[i] = L[i-1] + a
for i in range(N):
  D[i] = L[-1]-L[i]
#L.pop(0)
  
#print(L)
#print(D)
ans = 1e19
for i in range(N):
  #print(L[i],D[i],L[i]-D[i])
  ans = min(abs(L[i]-D[i]),ans)
print(ans)

Measured memory_bytes: 36292
n,m = map(int, input().split())
mod = 10**9+7

#フィボナッチ数列
dp = [0 for i in range(n+2)]
dp[0] = 1
dp[1] = 1
for i in range(2,n+2):
    dp[i] = dp[i-1] + dp[i-2]

#穴が無い場合
if m==0:
    print(dp[n]%mod)
    exit()

lst = []
for i in range(m):
    lst.append(int(input()))
lst.sort()

#2連続穴がある場合
for i in range(len(lst)-1):
    if lst[i]+1 == lst[i+1]:
        print(0)
        exit()

lst2 = []
for i in range(len(lst)):
    if i==0:
        lst2.append(lst[0]-1)
    else:
        lst2.append(lst[i]-lst[i-1]-2)
lst2.append(n-lst[-1]-1)

ans = 1
for i in lst2:
    ans *= dp[i]
    ans %= mod

# print(lst)
# print(lst2)
print(ans)


Measured memory_bytes: 464164
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

vector<long long> a;
long long N;
long long fib[30];

int main() {
  fib[1] = 1;
  rep(i, 28) {
    fib[i+2] = fib[i+1] + i + 2;
  }

  cin >> N;
  long long x = N;
  for(long long i = 2; i*i<=x; i++) {
    long long count = 0;
    while(N%i == 0) {
      count++;
      N /= i;
    }
    if(count != 0) a.push_back(count);
  }
  if(N!=1) {
    a.push_back(1);
  }
  long long ans = 0;

  for(long long i = 0; i < a.size(); i++) {
    bool f = false;
    for(long long j = 1; j <= 29; j++) {
      if(a[i] < fib[j]) {
        ans += j - 1;
        f = true;
        break;
      }
      if(a[i] == fib[j]) {
        ans += j;
        f = true;
        break;
      }
    }
    if(f) continue;
  }
  // rep(i, a.size()) {
  //   cout << a[i] << endl;
  // }
  // rep(i, 10) {
  //   cout << fib[i] << endl;
  // }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

	    int N=gi();
	    int K=gi();
	    int[] A=new int[N];

	    int min=Integer.MAX_VALUE;
	    int mi=0;
        for(int i=0; i<N;i++) {
        	A[i]=gi();
        	if(min>A[i]) {
        		min=A[i];
        		mi=i;
        	}
        }

        int s=0;
        int e=N-1;

        int n=(int)Math.ceil((double)(e-s)/(double)(K-1));
        System.out.println(n);

		//System.out.println();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 59204
#include <bits/stdc++.h>
#define int long long 
#define pb push_back
#define fr first
#define sc second
#define sz(v) ((int)(v).size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repd(i,a,p) for(int i=a-1;i>=p;i--) 
#define M 1000000007
#define vi vector<int>
#define vp vector<pair<int,int> >
#define ml map<int,int>
#define MPI 3.1415926536
using namespace std;
int temp=0,r,l,w,k=0,m1,e,p,q,ans,k1=0,k2=0,d=0,a=0,b=0,s=0,x,y,min1=1000000010,max1=0,m,c=0,t=0,i,n,c1=0,tot=0,t1,k4=0,c2=0,j=0,k3=0;char ch,ch1,ch2;string s1,s2,s3;
signed main()
{
cin>>n>>k;
vi v1(n),v2(n);
rep(i,0,n)cin>>v1[i]>>v2[i];
int dp[n+1][k+1];
rep(i,0,n+1)
{
	rep(j,0,k+1)
	{
		if(i==0||j==0)
		dp[i][j]=0;
	}
}
rep(i,1,n+1)
{
	rep(j,1,k+1)
	{
		if(v1[i-1]<=j)
		dp[i][j]=max(v2[i-1]+dp[i-1][j-v1[i-1]],dp[i-1][j]);
		else
		dp[i][j]=dp[i-1][j];
	}
}
cout<<dp[n][k];
}

Measured memory_bytes: 79104
#include<iostream>
#include<string>
using namespace std;
int alignment(string s,string t){


	int a[1001][1001]={};
	int n=s.size();
	int m=t.size();
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(s[i]==t[j]){
					a[i+1][j+1]=max(a[i][j]+1,max(a[i+1][j],a[i][j+1]));
				}else{
					a[i+1][j+1]=max(a[i][j],max(a[i+1][j],a[i][j+1]));
				}
			}
		}
	return a[n][m];
}

int main(void){

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

		string s;
		string t;
		cin >> s >> t;
		cout << alignment(s,t) <<endl;
	}
	
}


Measured memory_bytes: 7108