akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		Integer length = s.nextInt();
		String[] seq = new String[length];
		for(int i = 0; i < length; i++){
			seq[i] = s.next();
		}
		s.close();
		String[] seq_bubble = seq.clone(); 
		String[] seq_select = seq.clone(); 

		for(int i = 0; i < length; i++){
			for(int j = length - 1; j > i; j--){
				Integer value_a = Integer.parseInt(seq_bubble[j].substring(1));
				Integer value_b = Integer.parseInt(seq_bubble[j - 1].substring(1));
				if(value_a < value_b){
					String bkp = seq_bubble[j];
					seq_bubble[j] = seq_bubble[j - 1];
					seq_bubble[j - 1] = bkp;
				}
			}
		}

		for(int i = 0; i < length; i++){
			Integer mini = i;
			for(int j = i; j < length; j++){
				Integer value_a = Integer.parseInt(seq_select[j].substring(1));
				Integer value_b = Integer.parseInt(seq_select[mini].substring(1));
				if(value_a < value_b){
					mini = j;
				}
			}
			String bkp = seq_select[i];
			seq_select[i] = seq_select[mini];
			seq_select[mini] = bkp;
		}
		print_seq(seq_bubble, length);
		System.out.println("Stable");
		print_seq(seq_select, length);
		boolean is_reliable = true;
		for(int i = 0; i < length; i++){
			if(!seq_bubble[i].equals(seq_select[i])){
				is_reliable = false;
				break;
			}
		}
		if(is_reliable){
			System.out.println("Stable");
		}
		else{
			System.out.println("Not stable");
		}
			
	}

	private static void print_seq(String[] seq, Integer length){
		for(int i = 0; i < length; i++){
			if(i == length - 1){
				System.out.print(seq[i] + "\n");
			}
			else{
				System.out.print(seq[i] + " ");
			}
		}
		
	}
}

Measured memory_bytes: 17468
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(void) {
    string s; cin >> s;
    bool flag = false;
    rep(i, 3) {
        if(s[i]==s[i+1]) flag = true;
    }
    if(flag) cout <<"Bad";
    else cout << "Good";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){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;}

/*
1 x y
    s[x]=y
2 x y
    文字種を答える
*/

template<typename Monoid>
struct SegmentTree{
    using F = function< Monoid(Monoid, Monoid) >;
    //sz:size->完全二分木なのでszはnよりも大きい最小の2のべき乗数
    int sz;
    vector<Monoid> seg;
 
    const F f;
    const Monoid M1;
    SegmentTree(int n,const F f,const Monoid &M1) : f(f), M1(M1) {

    sz=1;
    while(sz<n) sz<<=1;
    seg.assign(2*sz, M1);
    }
 
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
 
    void build(){
        for(int k=sz-1;k>0;k--){
        seg[k]=f(seg[2*k+0], seg[2*k+1]);
        }
    }
 
    void update(int k,const Monoid &x){
        k+=sz;
        seg[k]=x;
        
    while(k>>=1){
        seg[k]=f(seg[2*k+0],seg[2*k+1]);
        }
    }
    //query聞くときは区間は[a,b)で(a<=x<b)
    Monoid query(int a, int b) {
        Monoid L=M1,R=M1;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
            if(a&1) L=f(L, seg[a++]);
            if(b&1) R=f(seg[--b], R);
        }
        return f(L,R);
    }   
    Monoid operator[](const int &k) const{
        return seg[k+sz];
    }
};
int f(int a,int b){return a+b;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    string s;cin>>s;
    int q;cin>>q;

    vector<SegmentTree<int>> segs;
    rep(i,26){
        char x='a'+i;
        SegmentTree<int> seg(n,f,0);
        rep(j,n){
            if(s[j]==x) seg.set(j,1);
            else        seg.set(j,0);
        }
        seg.build();
        segs.push_back(seg);
    }

    while(q--){
        int t;cin>>t;
        if(t==2){
            int x,y;cin>>x>>y;
            x--;
            int ans=0;
            rep(i,26){
                if(segs[i].query(x,y)>0) ans++;
            }
            cout<<ans<<endl;
        }
        else{
            int x;char y;cin>>x>>y;
            x--;
            segs[s[x]-'a'].update(x,0);
            segs[y-'a'].update(x,1);
            s[x]=y;
        }
    }
    return 0;
}


Measured memory_bytes: 144148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {

        static void Main()
        {
            //ここから
            long[] str = ReadLineToLongArray();
            long a = str[0];
            long b = str[1];
            long c = str[2];

            long ans;

            if (a+b >= c)
            {
                ans = b + c;
            }
            else{
                ans = a + 2 * b + 1;
            }

            //ここまで

            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }



        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }



    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >

int32_t main()
{
    fast;
    int a,b,c;
    cin>>a>>b>>c;
    int val=(b/a);
    cout<<min(val,c)<<endl;
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::max;

fn main() {
    let v: Vec<i32> = read_vec();
    let a = v[0];
    let b = v[1];
    println!("{}", max(a + b, max(a - b, a * b)));
}


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

int main(){
    int n;cin>>n;
    ll sum=0;
    vl a(n);rep(i,n){cin>>a[i];a[i]--;}

    vl cnt(n);rep(i,n)cnt[a[i]]++;
    rep(i,n)sum+=cnt[i]*(cnt[i]-1)/2;//全体

    vl ans(n);
   rep(i,n){
       ans[i]=sum-cnt[a[i]]+1;
       cout<<ans[i]<<endl;
   }

    
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int N,M;
bool a[8][8];

int main(){
    int x,y;
    long long count = 0;
    cin >> N >> M;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            a[i][j] = false;
        }
    }
    for(int i=0;i<M;i++){
        cin >> x >> y;
        a[x-1][y-1] = a[y-1][x-1] = true;
    }
    int b[N];
    for(int i=0;i<N;i++){
        b[i] = i;
    }
    bool f;
    do{
        f = true;
        for(int i=0;i<N-1;i++){
            if(b[0] != 0){
                f = false;
                break;
            }
            if(a[b[i]][b[i+1]]) continue;
            f = false;
            break;
        }
        if(f) count++;
    }while(next_permutation(b, b + N));
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
long long n,m,p;
vector<long long> d;
cin>>n>>m>>p;
for(int i=0;i<m;i++){
long long pos;
cin>>pos;
d.push_back(pos);
}
sort(d.begin(),d.end());
long long nearnext=0;
long long nextf=0;
long long nearback=m-1;
for(int i=0;i<m;i++){
if(p<d[i]&&nextf==0){
nextf=1;
nearnext=i;
}
if(p>d[i]){
nearback=i;
}
}
long long ans;
if(d[nearback]<p){
ans=d[nearback]+n-p;
}
else{
ans=d[nearback]-p;
}
//cout<<ans*100<<endl;
if(d[nearnext]>p){
ans=min(ans,p+n-d[nearnext]);
}
else{
ans=min(ans,p-d[nearnext]);
}
//cout<<ans*100<<endl;
for(int i=0;i<m;i++){
long long ret=d[i];
long long goal=d[(i+1)%m];
long long go,back;
if(ret<p){
go=ret+n-p;
}
else{
go=ret-p;
}
if(goal>p){
back=p+n-goal;
}
else{
back=p-goal;
}
ans=min(ans,go*2+back);
}
//cout<<ans*100<<endl;
for(int i=0;i<m;i++){
long long ret=d[i];
long long goal=d[(i+1)%m];
long long go,back;
if(ret<p){
go=ret+n-p;
}
else{
go=ret-p;
}
if(goal>p){
back=p+n-goal;
}
else{
back=p-goal;
}
ans=min(ans,go+back*2);
}
cout<<ans*100<<endl;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
const int SIZE = 1<<18;
struct segtree{
	int seg[SIZE*2];
	void init(){
		for(int i=0;i<SIZE*2;i++)seg[i]=0;
	}
	void update(int k,int x){
		k+=SIZE-1;
		seg[k]=max(seg[k],x);
		while(k){
			k=(k-1)/2;
			seg[k]=max(seg[k*2+1],seg[k*2+2]);
		}
	}
	int query(int a,int b,int k=0,int l=0,int r=SIZE){
		if(r<=a||b<=l)return -INF;
		else if(a<=l&&r<=b)return seg[k];
		else{
			int lch = query(a,b,k*2+1,l,(l+r)/2);
			int rch = query(a,b,k*2+2,(l+r)/2,r);
			return max(lch,rch);
		}
	}
}seg;
P s,t;
int N;
vector<P> vec;
vector<int> zipx;
bool comp(const P& a,const P& b){
	return a.sec<b.sec;
}
int main(){
	seg.init();
	cin >> s.fi >> s.sec;
	cin >> t.fi >> t.sec;
	if(s.fi>t.fi)swap(s,t);
	int limit = min(abs(s.fi-t.fi),abs(s.sec-t.sec))+1;
	double ans = (double)(abs(s.fi-t.fi)+abs(s.sec-t.sec))*(double)100.0;
	zipx.pb(s.fi);zipx.pb(t.fi);
	cin >> N;
	vec.resize(N);
	for(int i=0;i<N;i++){
		cin >> vec[i].fi >> vec[i].sec;
		zipx.pb(vec[i].fi);
	}
	/*if(s.fi==t.fi){
		double add = 10.0*M_PI-20.0;
		for(int i=0;i<N;i++){
			if(vec[i].fi==s.fi&&vec[i].sec>min(s.sec,t.sec)&&vec[i].sec<max(s.sec,t.sec)){
				ans += add;
			}
		}
		printf("%.15f\n",ans);
		return 0;
	}
	if(s.sec==t.sec){
		double add = 10.0*M_PI-20.0;
		for(int i=0;i<N;i++){
			if(vec[i].sec==s.sec&&vec[i].fi>min(s.fi,t.fi)&&vec[i].fi<max(s.fi,t.fi)){
				ans += add;
			}
		}
		printf("%.15f\n",ans);
		return 0;
	}*/
	if(s.sec>t.sec){
		for(int i=0;i<N;i++)vec[i].sec*=-1;
		s.sec*=-1;
		t.sec*=-1;
	}
	sort(all(zipx));
	zipx.erase(unique(all(zipx)),zipx.end());
	for(int i=0;i<N;i++)vec[i].fi=lower_bound(all(zipx),vec[i].fi)-zipx.begin();
	s.fi = lower_bound(all(zipx),s.fi)-zipx.begin();
	t.fi = lower_bound(all(zipx),t.fi)-zipx.begin();
	sort(all(vec),comp);
	vector<int> zipy;
	for(int i=0;i<vec.size();i++)zipy.pb(vec[i].sec);
	/*for(int i=0;i<vec.size();i++){
		cout << vec[i].fi << ' ' << vec[i].sec << endl;
	}*/
	int S = lower_bound(all(zipy),s.sec)-zipy.begin();
	int T = upper_bound(all(zipy),t.sec)-zipy.begin();
	for(int i=S;i<T;i++){
		int upd = seg.query(s.fi,vec[i].fi+1)+1;
		seg.update(vec[i].fi,upd);
	}
	int ma = seg.query(s.fi,t.fi+1);
	if(ma<limit){
		double add = 5.0*M_PI-20.0;
		ans += add*ma;
		printf("%.15f\n",ans);
	}else{
		double add = 5.0*M_PI-20.0;
		double add2 = 10.0*M_PI-20.0;
		ans += add*(ma-1);
		ans += add2;
		printf("%.15f\n",ans);
	}
	return 0;
}

Measured memory_bytes: 6132
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	int grid[3][3];

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> grid[i][j];
		}
	}

	int difA[2], difB[2];
	difA[0] = grid[0][1] - grid[0][0];
	difA[1] = grid[0][2] - grid[0][1];
	difB[0] = grid[1][0] - grid[0][0];
	difB[1] = grid[2][0] - grid[1][0];
	bool flag = true;
	for (int i = 1; i < 3; i++) {
		for (int j = 0; j < 2; j++) {
			if (difA[j] != grid[i][j + 1] - grid[i][j]) {
				flag = false;
			}
			if (difB[j] != grid[j + 1][i] - grid[j][i]) {
				flag = false;
			}
		}
	}
	if (!flag) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        int cnt = 0;
        while (a % 2 == 0) {
            a /= 2;
            cnt++;
        }
        res += cnt;
    }
    cout << res << endl;
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    cout << n*n*n << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
const ll MOD = 1e9+7;

ll mod(ll a){
  if(a==0) return 1;
  return (mod(a-1)%MOD)*a;
}
 
int main(){
  int n; cin >> n;
  cout << mod(n)%MOD << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    while(1){
        int a,b,i,j;
        cin >> a >> b;
        if(a==0 && b==0){
            break;
        }
        else{
            for(j=0; j<a; j++){
                for(i=0; i<b; i++){
                    if(i==(b-1)){
                        cout << "#" << endl;
                    }
                    else{
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
    }
    return 0;
}



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

const int INF = 1000000000;

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

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(C[i][j]>C[i][k]+C[k][j]){
            C[i][j] = C[i][k]+C[k][j];
          }
          if(T[i][j]>T[i][k]+T[k][j]){
            T[i][j] = T[i][k]+T[k][j];
          }
        }
      }
    }

    int k;
    cin >> k;

    int p,q,r;

    for(int i=0;i<k;i++){
      cin >> p >> q >> r;
      if(r == 0){
        cout << C[p-1][q-1] << endl;
      }
      else{
        cout << T[p-1][q-1] << endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3172
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
vector<ll> A;
ll ruiseki[214514];
pair<ll,ll> nibutan(int start,int end){
	int ok=start,ng=end;
	ll sum=ruiseki[end]-ruiseki[start];
	while(ng-ok>1){
		int mid=(ng+ok)/2;
		ll dif = ruiseki[mid]-ruiseki[start];
		if(2*dif <=sum) ok=mid;
		else ng=mid;
	}
	//cout<<ok<<" "<<ng<<endl;
	ll dif=min(abs((ruiseki[end]-ruiseki[ng])-(ruiseki[ng]-ruiseki[start])), abs((ruiseki[end]-ruiseki[ok])-(ruiseki[ok]-ruiseki[start])));
	return mp((sum-dif)/2,(sum+dif)/2);
}
int main(){
	int N;
	cin>>N;
	ll sum=0;
	ruiseki[0]=(ll)0;
	rep(i,N){
		ll x;
		cin>>x;
		sum+=x;
		A.pb(x);
		ruiseki[i+1]=sum;
	}
	/*pair<ll,ll> X=nibutan(0,N);
	cout<<X.first<<" "<<X.second<<endl;*/
	ll ans=(ll)2*1e14;
	for(int mid=2;mid<N-1;mid++){
		vector<ll> hoge;
		pair<ll,ll> X=nibutan(0,mid),Y=nibutan(mid,N);
		hoge.pb(X.first);
		hoge.pb(X.second);
		hoge.pb(Y.first);
		hoge.pb(Y.second);
		sort(all(hoge));
		ans=min(ans,hoge[3]-hoge[0]);
	}
	cout<<ans<<endl;
}


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


def main():
    N, M = map(int, input().split())
    INF = 10 ** 10
    p = 2 ** N
    dp = [INF] * p
    dp[0] = 0

    for _ in range(M):
        a, b = map(int, input().split())
        c = sum([2 ** (i - 1) for i in map(int, input().split())])
        for i in range(p):
            if dp[i | c] > dp[i] + a:
                dp[i | c] = dp[i] + a

    if dp[-1] != INF:
        print(dp[-1])
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll A[5];
        for(ll i=0;i<5;i++)
        {
            cin>>A[i];
            if(A[i]==0)
            {
                cout<<i+1;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
int main(){
	ll a,b,c,k; cin >>a >>b>>c>>k;
	if(k%2==0){
		cout << a-b << endl;
	}
	else{
		cout << b-a << endl;
	}
}

Measured memory_bytes: 256
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, X, Y = get_ints

@res = Array.new(N+1) { [] }

def bfs(from, node, weight)
  return if @res[from][node] && @res[from][node] < weight

  @res[from][node] = weight

  bfs(from, node - 1, weight + 1) if node > 1
  bfs(from, node + 1, weight + 1) if node < N
  bfs(from, Y, weight + 1) if node == X
  bfs(from, X, weight + 1) if node == Y
end

1.step(N) do |i|
  bfs(i, i, 0)
end

result = Array.new(N+1, 0)
1.step(N) do |i|
  (i+1).step(N) do |j|
    result[@res[i][j]] += 1
  end
end

1.step(N-1) do |i|
  puts result[i]
end


Measured memory_bytes: 52172
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int n;
int v[100000];
int cnt[2][100000];
vector<P> vec1, vec2;

int main() {
	int i, j;
	
	cin >> n;
	rep(i, n) {
		cin >> v[i];
		v[i]--;
		cnt[i % 2][v[i]]++;
	}
	
	rep(i, 100000) {
		vec1.push_back(P(n/2 - cnt[0][i], i));
		vec2.push_back(P(n/2 - cnt[1][i], i));
	}
	sort(vec1.begin(), vec1.end());
	sort(vec2.begin(), vec2.end());
	
	int ans = 114514;
	rep(i, 2) {
		rep(j, 2) {
			if (vec1[i].second == vec2[j].second) continue;
			ans = min(ans, vec1[i].first + vec2[j].first);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
n = int(input())
*a, = map(int, input().split())
for i in range(n):
  v = a[i]
  j = i -1
  while j >= 0 and a[j] > v:
    a[j+1] = a[j]
    j = j - 1
  a[j+1] = v
  print(*a)


Measured memory_bytes: 5976
import math 
  
# function to print number of 
# digits 
def findNumberOfDigits(n, base): 
      
    # Calculating log using base 
    # changing property and then 
    # taking it floor and then  
    # adding 1. 
    dig = (math.floor(math.log(n) /
                 math.log(base)) + 1) 
      
    # printing output 
    return dig

a, b = [int(i) for i in input().split()]

print(findNumberOfDigits(a,b))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;

int main() {
    int N;
    cin >> N;
    int even = 1;
    int count = 0;
    while(N >= even){
        even *= 2;
        count++;
    }
    cout << pow(2,count-1) << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   double a,b,x;
   cin >> a >> b >> x;
   if((a*a*b)/2<=x) cout << fixed << setprecision(10)<< atan((2*(a*a*b-x))/(a*a*a))*(180/acos(-1)) << endl;
   else cout << fixed << setprecision(10) << atan((a*b*b)/(2*x))*(180/acos(-1)) << endl;
}

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

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

  vector<int> A(M);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
  }

  int64_t res=0;
  for (int i = 0; i < M; i++) {
    res+= A.at(i);
  }

  int64_t res1;
  res1=N-res;
  if (res1<0) res1=-1;

  cout << res1 << endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
int a[114514];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	if (a[n - 1] - a[0] >= 2) {
		puts("No");
	}
	else if (a[n-1]-a[0]==0) {
		if (a[0] == n - 1 || 2 * a[0] <= n) {
			puts("Yes");
		}
		else puts("No");
	}
	else {
		int cnt = 0;
		rep(i, n) {
			if (a[i] == a[0])cnt++;		
		}
		if (a[n - 1] - cnt <= 0)puts("No");
		else if (2 * a[n - 1] - cnt <= n)puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (auto i = std::size_t(0); i < H; ++i) {
            for (auto j = std::size_t(0); j < W; ++j) {
                if ((i + j) % 2 == 0) cout << "#";
                else cout << ".";
            }
            cout << "\n";
        }
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<vector<ll>> x(n,vector<ll>(3));
    rep(i,n)rep(j,3) cin>>x[i][j];
    ll res=0;
    for(int tmp=0;tmp<(1<<3);tmp++){
        bitset<3> s(tmp);
        priority_queue<ll> que;
        ll ans=0;
        rep(i,n){
            ll now=0;
            rep(j,3) if(s[j]==0)now-=x[i][j];else now+=x[i][j];
            que.push(now);
        }
        rep(i,m){
            ans+=que.top();que.pop();
        }
        res=max(ans,res);
    }
    cout<<res<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int solve(){
    ll n,d;
    cin>>n>>d;
    vector<ll> v(n);
    vector<ll> v1(n);
    for (int i = 0; i < n; i++)
    {   
        ll a,b;
        cin>>a>>b;
        v[i]=abs(a);
        v1[i]=abs(b);
    }

    int cnt=0;
    for (int i = 0; i < n; i++)
    {
        ll d1=v[i]*v[i];
        ll d2= v1[i]*v1[i];
        ll d3=d1+d2;
        if(d3<=d*d){
           cnt++; 
        }
    }
    
    cout<<cnt;
    
    return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cerr<<fixed<<setprecision(10);
  auto start = chrono::high_resolution_clock::now();
  int t=1;
  //cin>>t;
  while(t--)
    solve(),cout<<"\n";

  auto stop = chrono::high_resolution_clock::now(); 
  auto duration = chrono::duration_cast<chrono::nanoseconds>(stop - start); 
  //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s \n";      
  
  return 0;
}

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

int n, m, reduceN, reduceM;

long long F[200001];
long long invF[200001];
long long mod = 1000000000 + 7;

long long power(long long x, long long e)
{
	long long ret = 1;
	while(e > 0)
	{
		if(e % 2 == 1) ret = (ret * x) % mod;
		x = (x * x) % mod;
		e /= 2;
	}
	return ret;
}

long long inv(long long x)
{
	return power(x, mod - 2);
}

long long C(int a, int b)
{
	long long ret = F[a];
	ret *= invF[b];
	ret %= mod;
	ret *= invF[a-b];
	ret %= mod;
	return ret;
}

long long ways(int dx, int dy)
{
	return C(dx + dy, dx);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	F[0] = invF[0] = 1;
	for(int i = 1; i <= 200000; i++)
	{
		F[i] = (F[i-1] * i) % mod;
		invF[i] = inv(F[i]);
	}

	cin >> n >> m >> reduceN >> reduceM;
	reduceN = n - reduceN + 1;

	long long ret = ways(n-1, m-1);

	for(int i = 1; i <= reduceM; i++)
	{
		ret -= ways(n- reduceN, m - i) * ways(reduceN - 1 - 1, i - 1);
		//cout << (n- reduceN) << " " <<  (m - i) << " * " << (reduceN - 1) <<  " " << (i - 1) << endl;
		ret %= mod;
		ret += mod;
		ret %= mod;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,x,a);
  OUT((x<a?"0":"10"))BR;
  
  return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    string ans;
    if (a < b) swap(a, b);
    string str = to_string(b);
    rep(i,a) ans.insert(i,str);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while true
  date = gets.scan(/\-?[0-9]+/)
  break   if date[0].to_i == -1 && date[1].to_i == -1 && date[2].to_i == -1 && date[3].to_i == -1 && date[4].to_i == -1 && date[5].to_i == -1
  day_source = Time.local(date[0], date[1], date[2], 0, 0, 0)
  day_target = Time.local(date[3], date[4], date[5], 0, 0, 0)
  difference = (day_target - day_source).divmod(24*60*60)
  puts difference[0].to_i
end

Measured memory_bytes: 6140
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define fo(x,a,b) for(register int x=a;x<=b;x++)
#define dfo(x,a,b) for(register int x=a;x>b;x--)
#define inf 2147483647
using namespace std;
bool bz[505][505];
int r,c,x,y,n,dx,dy,ans;
int main ()
{
	//freopen("szs.in","r",stdin);
	//freopen("szs.out","w",stdout);

	while (true) 
	{
		scanf("%d",&n);
		ans=0;
		if (n==0) break;
		scanf("%d%d",&x,&y);
		memset(bz,false,sizeof(bz));
		fo(i,1,n)
		{
			scanf("%d%d",&dx,&dy);
			bz[dx][dy]=true;
		}
		scanf("%d%d",&r,&c);
		fo(i,1,x-r+1)
		{
			fo(j,1,y-c+1)
			{
				int cnt=0;
				fo(xx,i,i+r-1)
				{
					fo(yy,j,j+c-1)
					{
						if (bz[xx][yy]) cnt++;	
					}
				}
				ans=max(ans,cnt);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}





Measured memory_bytes: 3452
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  string s;
  cin>>s;
  if(s=="ABC")cout<<"ARC"<<"\n";
  else cout<<"ABC"<<"\n";
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		long mod = (long)1e9+7;
		char[][] a = new char[h][w];
		long[][] dp = new long[h][w];
		for (int i = 0; i < h; i++) a[i] = sc.next().toCharArray();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if(a[i][j] == '.') {
					if(j-1>=0&&a[i][j-1]=='.') {
						dp[i][j] += dp[i][j-1];
						dp[i][j] %= mod;
					}
					if(i-1>=0&&a[i-1][j]=='.') {
						dp[i][j] += dp[i-1][j];
						dp[i][j] %= mod;
					}
					if(i==0&&j==0) dp[i][j] = 1;
				}
			}
		}
		System.out.println(dp[h-1][w-1]);
		sc.close();
	}
}

Measured memory_bytes: 51804
s=list(input())

cnt=1
a=[]
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        a.append(cnt)
        cnt=1
    else:
        cnt+=1
a.append(cnt)

ans=[]
for j in range(len(a)//2):
    p=a[2*j]
    q=a[2*j+1]
    r=p+q
    s=r//2
    if s==r-s:
        ans+=([0]*(p-1))+[s,r-s]+([0]*(q-1))
    elif p>q:
        if p%2==1:
            ans+=([0]*(p-1))+[r-s,s]+([0]*(q-1))
        else:
            ans+=([0]*(p-1))+[s,r-s]+([0]*(q-1))
    else:
        if q%2==0:
            ans+=([0]*(p-1))+[r-s,s]+([0]*(q-1))
        else:
            ans+=([0]*(p-1))+[s,r-s]+([0]*(q-1))
print(*ans)

Measured memory_bytes: 7104
N, X, Y = map(int, input().split())

ans = [0 for i in range(N)]

def dist(i,j):
  # Use Path
  r1 = abs(i-j)
  # Move i -> X -> Y -> j
  r2 = abs(i-X) + 1 + abs(j-Y)
  # Move i -> Y -> X -> j
  r3 = abs(i-Y) + 1 + abs(j-X)
  return(min(r1,r2,r3))

for i in range(1, N+1):
  for j in range(i+1, N+1):
    ans[ dist(i,j) ] += 1

for i in range(1,N):
  print(ans[i])

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

int main(){
  string s;
  int count=0;
  cin >> s;

  for(int i=1;i<s.size();i++){
    if(s.at(i) == s.at(i-1)){
      if(s.at(i) == '0'){
        s.at(i)='1';
      }else{
        s.at(i)='0';
      }
      ++count;
    }
  }

  cout << count << endl;
}

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

int main () {
 string s;
  cin >> s;
  int hajime=200000;
  int owari=0;
  for(int i=0;i<s.size();i++){
   
    if(s.at(i)=='A'&& i<hajime){
      hajime=i;
    }
   
    if(s.at(i)=='Z'&& owari<i){
      owari=i;
    }
  }
  cout << owari-hajime+1<<endl;
}




Measured memory_bytes: 640
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
	if(m ==0) return 1;
	if(i >= n) return 0;
	int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
	return res;
}

int main(){
	int q,m,i;
	
	scanf("%d",&n);
	for(i = 0;i < n;i ++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i = 0;i < q;i ++){
		scanf("%d",&m);
		if(solve(0,m)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


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

typedef long long ll;

int main(){
    string a, b;
    cin >> a >> b;
    
    if(a.length()>b.length()){
        cout << "GREATER" << endl;
    }
    else if(a.length()<b.length()){
        cout << "LESS" << endl;
    }
    else{
        if(a>b) cout << "GREATER" << endl;
        else if(a<b) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
    }
}


Measured memory_bytes: 256
// D - Leaping Tak
#include <bits/stdc++.h>

using namespace std;

#define	MOD	998244353

void fen_update(vector<long long> &tree, int i, long long delta)
{
	for ( ; i < tree.size(); i |= i + 1) tree[i] = (tree[i] + delta) % MOD;
}

long long fen_get(const vector<long long> &tree, int i)
{
	long long sum = 0;
	for ( ; i > 0; i &= i - 1) sum = (sum + tree[i - 1]) % MOD;
	return sum;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> s(k);
	for (int i = 0; i < k; i++)
		cin >> s[i].first >> s[i].second;
	sort(s.begin(), s.end());
	vector<long long> t(n);
	fen_update(t, 0, 1);
	for (int i = 1; i < n; i++)
		for (auto x : s) {
			if (i - x.first < 0) break;
			int r = max(0, i - x.first), l = max(0, i - x.second);
			long long d = (fen_get(t, r + 1) - fen_get(t, l) + MOD) % MOD;
			fen_update(t, i, d);
		}

	cout << (fen_get(t, n) - fen_get(t, n - 1) + MOD) % MOD << endl;

	return 0;
}


Measured memory_bytes: 4776
def resolve():
    n, m = map(int, input().split())

    student_position = list()
    for i in range(n):
        a, b = map(int, input().split())
        student_position.append([a, b])
    
    check_point = list()
    for i in range(m):
        c, d = map(int, input().split())
        check_point.append([c, d])

    ans = list()
    for student_num in range(n):
        delta_list = list()
        for point_num in range(m):
            x = abs(student_position[student_num][0] - check_point[point_num][0])
            y = abs(student_position[student_num][1] - check_point[point_num][1])
            delta = x + y
            delta_list.append(delta * 100 + point_num)
        nearest_index = min(delta_list)
        point = nearest_index % 100 + 1
        ans.append(point)
    
    for an in ans:
        print(an)
resolve()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int test[345678], kari[345678];
signed main() {
	int n, a, ans = 0; cin >> n;
	map<int, int> cnt;
	for (int h = 0; h < n; h++) {
		cin >> test[h]; kari[h] = test[h];
	}
	sort(kari, kari + n);
	for (int h = 0; h < n; h += 2) {
		cnt[kari[h]] = 1;
	}
	for (int h = 0; h < n; h += 2) {
		if (cnt[test[h]] == 0) { ans++; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9344
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,k;cin>>n>>k;
    ll cnt=0;
    if(k%2==0){
        ll t=n/k;
        ll ans=t*t*t;
        
        cnt=(n/(k/2)-n/k);
        cout<<(ll)ans+cnt*cnt*cnt<<endl;
    }
    else{
        cnt=n/k;
        cout<<(ll)cnt*cnt*cnt<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s; cin >> s;
	int len = s.size();
	for(int c = 'a'; c <= 'z'; c++){
		vector<int> vals(len, 1);
		for(int j = 0; j < len; j++) if(s[j] == c) vals[j] -= 2;
		for(int j = 1; j < len; j++) vals[j] += vals[j - 1];
		int mx = -(1<<30), pos = -1;
		for(int j = 0; j < len; j++) {
			if(vals[j] - mx < 0){
				cout << pos + 2 << " " << j + 1 << endl;
				return 0;
			}
			if(j == 0) mx = 0;
			else if(mx < vals[j - 1]) mx = vals[j - 1], pos = j - 1;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define ull unsigned long long
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
    FIO;
   ll a, b, c;  cin >> a >> b >> c;
   ll d = ceil(a/(b * 1.0));
   cout << d * c << endl;

    return 0;
}


Measured memory_bytes: 3728
from collections import deque
H,W = map(int, input().split())
m = [input() for _ in range(H)]
visited=[[0]*W for _ in range(H)]
dhw = [(1,0),(-1,0),(0,1),(0,-1)]
def main():
  global visited
  for h in range(H):
    for w in range(W):
      if m[h][w]==".":
        continue
      for dh, dw in dhw:
        nh, nw = h+dh, w+dw
        if 0<=nh<H and 0<=nw<W:
          if m[nh][nw]=="#":
            break
      else:
        print("No")
        return
  print("Yes")
  return

if __name__ == "__main__":
  main()

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



using ll=long long;
int main(){
	
	
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
	#endif
	
	ll h,a,n,k,i;
	cin>>n>>k;
	ll arr[n];
	ll sum=0;
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	ll tt=n-k;
	for(i=0;i<tt;i++)sum+=arr[i];
	cout<<sum;
	
	
}

Measured memory_bytes: 1792
import java.util.*;

class Main{
    public static void main(String[] args){
        long X, Y, A, i=0;
        Scanner sc = new Scanner(System.in);
        X = sc.nextLong();
        Y = sc.nextLong();
        A = X;
        while(X <= A && A <= Y){
            A = A*2;
            i++;
        }
        System.out.println(i);
    }
}

Measured memory_bytes: 21844
S = input()

S1 = set(['R', 'U', 'D'])
S2 = set(['L', 'U', 'D'])
flag = 'Yes'
if not all(x in S1 for x in S[0::2]):
    flag = 'No'
if not all(x in S2 for x in S[1::2]):
    flag = 'No'
print(flag)

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

int main() {
  int n;
  cin>>n;
  vector<long long int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<vec.at(n-1)<<" ";
  long long int p=vec.at(n-1)*10;
  long long int answer;
  
  for(int i=0;i<n-1;i++){
    if(p>llabs(vec.at(n-1)-vec.at(i)*2)){
      answer=vec.at(i);
      p=llabs(vec.at(n-1)-vec.at(i)*2);
      }
    }
  cout<<answer<<endl;
}

Measured memory_bytes: 1024
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int a,p;
  cin >> a >> p;
  
  cout << int((3*a+p)/2) << endl;
 
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;//998'244'353;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

template<typename T>
T power(T x, long long n, const T &m){
    if(n == 0) return 1;
    if(n == 1) return x;
    T tmp = power(x, n/2, m);
    if(n%2 == 0) return tmp * tmp % m;
    else return tmp * tmp % m * x % m;
}

template<typename T>
T inverse(T x, const T &m){
    return power(x, m-2, m);
}

struct Combination{
    int N;
    long long M;
    vector<long long> f, i;
    void init(int n, long long m){
        N = n; M = m;
        f.resize(N+1); f[0] = 1;
        i.resize(N+1); i[0] = 1;
        for(long long j=1; j<=N; j++){
            f[j] = f[j-1]*j%M;
            i[j] = inverse(f[j], M);
        }
    }
    long long fact(int n){
        return f[n];
    }
    long long C(int n, int r){
        return f[n] * i[r] % M * i[n-r] % M;
    }
};

int N;
ll M;

Combination comb;

ll solve(int N){
    ll ans = 0;
    ll tmp = 1;
    rep(i, N/3+1){
        ans += tmp * comb.i[i];
        ans %= M;
        if(i == N/3) continue;
        tmp *= comb.C(N-2*i, 2);
        tmp %= M;
    }
    return ans;
}

signed main(){
    cin >> N >> M;
    comb.init(3*N, M);
    ll ans = 0;
    ll tmp = 1;
    rep(i, N+1){
        ans += solve(3*(N-i)) * tmp % M * comb.i[i];
        ans %= M;
        if(i == N) continue;
        tmp *= comb.C(3*(N-i), 3) * 2;
        tmp %= M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512