akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

typedef struct {
    ll time, dead;
} work;

int workcmp(const void *a, const void *b) {
    if ((*(work *)a).dead < (*(work *)b).dead) return -1;
    else if ((*(work *)a).dead == (*(work *)b).dead) return 0;
    else return 1;
}

int main(void) {
    int N;
    work W[200010];
    cin >> N;
    for (int i=0;i<N;i++) cin >> W[i].time >> W[i].dead;
    qsort(W, N, sizeof(work), workcmp);
    ll C = 0;
    for (int i=0;i<N;i++) {
        C += W[i].time;
        if (W[i].dead < C) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
int main() {
    ll n, k;
    cin >> n >> k;
    ll cnt = n / k;
    ll ans = cnt * cnt * cnt;
    if (k % 2 == 0) {
        cnt = (n + k / 2) / k;
        ans += cnt * cnt * cnt;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3600
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(int argc, char const* argv[])
{
  int n, q;
  cin >> n >> q;
  vector<vector<ll> > a(n);
  rep(i, q){
    int x;
    cin >> x;
    if(x == 0){
      int t;
      cin >> t;
      ll y;
      cin >> y;
      a[t].pb(y);
    }else if(x == 1){
      int t;
      cin >> t;
      rep(j, sz(a[t])){
        cout << a[t][j];
        if(j + 1 != sz(a[t])){
          cout << " ";
        }
      }
      cout << endl;
    }else{
      int t;
      cin >> t;
      a[t].clear();
    }
  }
	return 0;
}



Measured memory_bytes: 8744
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;


void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto A = s[1];
    auto B = s[2];
    auto X = readln.split.map!(to!long);

    long ans = 0;
    foreach (i; 1..N) {
        ans += min((X[i]-X[i-1])*A, B);
    }
    ans.writeln;
}


Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();}
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);}
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long N, long long K){
    int ans=0;
    while(N>0){
        N/=K;
        ans++;
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,k;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if(k<=a+b)cout<<(a<k?a:k);
	else cout<<a-(k-a-b);
	return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main(void){
      int N;
      cin >> N;
      double T,A;
      cin >> T >> A;
      vector<int> H(N);
      for(int i = 0; i < N; i++) cin >> H[i];
      int j = 0;
      double S = abs(A -(T-H[0]*0.006));
      double NowS = 0;
      for(int i = 0; i < N; i++){
          NowS = abs(A-(T-H[i]*0.006));
          //cout << NowS << endl;
          S = min(NowS,S);
          if(S == NowS) j = i + 1;
      }
      cout << j << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace M_SOLUTIONS
{
    class Program
    {
        static public int[] SIn() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static void Main(string[] args)
        {
            var line = ReadLine();
            var N = line.Length;
            var k = line.Count(e => e == 'o');
            if (15 - N >= 8 - k) WriteLine("YES");
            else WriteLine($"NO");
        }
    }
}


Measured memory_bytes: 13268
import java.math.*;
import java.io.*;
import java.util.*;

public class Main {
public static int gcd(int a, int b) 
    { 
      if (b == 0) 
        return a; 
      return gcd(b, a % b);  
    }
public static void main(String[] args) throws Exception{

    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	int n = Integer.parseInt(br.readLine());
      	int count = 0;
      	for(int i = 1; i <= n; i++)
      	{
      		for(int j = 1; j <= n; j++)
      		{
      			for(int k = 1; k <= n; k++)
      			{
      				count += gcd(gcd(i,j),k);
      			}
      		}
      	}
      	System.out.println(count);
    }

}




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

#[fastout]
fn main() {
    input!(
        n: f64,
    );

    if (n as isize) < 1000 {
        println!("{}", (n as isize - 1000).abs());
        return;
    }

    let ans = if n as isize % 1000 == 0{
        0
    } else {
        1000 * ((n / 1000.0).ceil() as isize) - (n as isize)
    };

    println!("{}", ans);
}


Measured memory_bytes: 2588
N = int(input())
A = list(map(int, input().split()))
X = []
total = 0

for i in range(1, N, 2):
    total += A[i]
    
X.append(sum(A) - 2 * total)

for i in range(N - 1):
    X.append(int(2 * (A[i] - X[i] / 2)))
    
for i in range(len(X)):
    print(X[i], end = " ")

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

typedef long long ll;
void solve(){
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    ll ans = 0;
    for (int i = 0; i < N-1; i++) {
        ans += S[i+1] == S[i];
    }

    cout << ans + min(2*K, N - ans - 1) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin  >> N >> A >> B;
  int price1,price2;
  price1 = N*A;
  price2 = B;
  if (price1<=price2){
    cout << price1 << endl;
  } else {
    cout << price2 << endl;
  }
}

Measured memory_bytes: 256
char buf[20000];sz;
int rd()
{
	int ret=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		ret=ret*10+k-'0';
	}
	return ret;
}
int d[3001];
const int mod=998244353;
main()
{
	read(0,buf,20000);
	int N=rd();
	int S=rd();
	int ans=0;
	for(int i=0;i<N;i++)
	{
		++d[S];
		for(int j=rd(),k=0;j<=S;j++,k++)
		{
			d[k]+=d[j];
			d[k]-=mod*(d[k]>=mod);
		}
		ans+=d[0];
		if(ans>=mod)ans-=mod;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,p;
    cin>>n>>k;
    std::deque<int> dice;
    for (int i=0;i<n;i++) {
        cin>>p;
        dice.emplace_back(p);
    }
    std::deque<int> s(n+1,0.0);
    for (int i=0;i<n;i++) {
        s[i+1]=s[i]+dice[i];
    }
    int ans;
    int max=0;
    for (int i=0;i+k<=n;i++) {
        if (s[i+k]-s[i]>max) {
            max=s[i+k]-s[i];
            ans=i;
        }
    }
    double sum=0.0;
    for (int j=ans;j<ans+k;j++) {
        if (dice[j]%2==0) {
            sum+=(1+dice[j])*(dice[j]/2)/double(dice[j]);
        } else {
            sum+=((1+dice[j])*(dice[j]/2)+(1+dice[j])/2)/double(dice[j]);
        }
    }
    printf("%.10f\n",sum);
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int N, MAX, sum=0;
  cin >> N;
  vector<int> v(N);
  REP(i,N) {
    cin >> v.at(i);
    sum+=v.at(i);
  }
  sort ALL(v);
  reverse ALL(v);
  MAX=v.at(0);
  if(MAX<sum-v.at(0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
    // 入力
    int N;
    int max,result=0;
    cin >> N;

    //cout << "" << endl;
    // 計算
    if (N%1000>0){
        result = 1000-N%1000;
    }else{
        result = 0;
    }

    // 出力
    cout << result << endl;
    return 0;  
}


Measured memory_bytes: 3632
function Main(input){
  var In = input.split('\n').map(Number);
  var mochi = [];
  var count = 0;
  var a = 0;
  
  for(var i = 1; i<= In[0]; i++){
    mochi.push(In[i]);
  }
  
  mochi.sort(function(a,b){return a-b;});
  
  for(var j = 0; j < In[0]; j++){
    if(mochi[j] > a){
      count += 1;
      a = mochi[j];
    }
  }
  
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
A=list()
B=list()
C=list()
C=[[0 for i in range(3)]for j in range(3)]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
for i in range(N) :
    B.append(int(input()))

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            C[i][j]=1
if C[0][0]*C[0][1]*C[0][2]==1:
    print("Yes")
elif C[1][0]*C[1][1]*C[1][2]==1:
    print("Yes")
elif C[2][0]*C[2][1]*C[2][2]==1:
    print("Yes")
elif C[0][0]*C[1][0]*C[2][0]==1:
    print("Yes")
elif C[0][1]*C[1][1]*C[2][1]==1:
    print("Yes")
elif C[0][2]*C[1][2]*C[2][2]==1:
    print("Yes")
elif C[0][0]*C[1][1]*C[2][2]==1:
    print("Yes")
elif C[0][2]*C[1][1]*C[2][0]==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N; ll mod;
vector<int> G[MAX_N];
ll ans[MAX_N];
ll dp[MAX_N];

void loop(int v, int p) {
	ll res = 1;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(n != p) {
			loop(n, v);
			MUL(res, dp[n] + 1);
		}
	}
	dp[v] = res;
}

void dfs(int v, int p, ll tmp) {
	vector<int> idx;
	vector<ll> mul;

	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(n != p) idx.pb(n);
	}
	int m = sz(idx);
	mul.resize(m + 1, 1);
	rer(i, m, 0) {
		mul[i] = mul[i + 1] * (dp[idx[i]] + 1) % mod;
	}
	ans[v] = dp[v] * tmp % mod;
	// debug(v, p, tmp, mul);
	ll tm = 1;
	rep(i, 0, m) {
		dfs(idx[i], v, (tmp * tm % mod * mul[i + 1] % mod + 1) % mod);
		MUL(tm, (dp[idx[i]] + 1));
	}
}

void solve() {
	cin >> N >> mod;
	rep(i, 0, N - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	loop(0, -1);
	dfs(0, -1, 1);
	rep(i, 0, N) {
		cout << ans[i] << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 30592
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  a = int(input())
  b = int(input())
  if a > b:
    print('GREATER')
  elif a < b:
    print('LESS')
  else:
    print('EQUAL')
if __name__ == '__main__':
  main()

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

typedef complex<double> P;

const double EPS = 1e-8;
const int N = 300;
const double R = 1;

struct Circle{
  P c;
  double r;
  Circle(P c=P(0,0), double r=0):c(c),r(r){}
};

vector<P> getIntersectCC(Circle c1, Circle c2){
  vector<P> res;
  double r1 = c1.r, r2 = c2.r, d;
  P p1 = c1.c, p2 = c2.c;
  d = abs(p1-p2);

  if(d < EPS && abs(r1-r2) < EPS) return res; //????????¨?????????????????´???????????????????????????????????????
  if(r1 + r2< d - EPS || d + EPS < abs(r1-r2)) return res; //???????????????

  double a = (r1*r1 - r2*r2 + d*d) / (2*d);
  double h = sqrt(max(r1*r1 - a*a, 0.0));
  P tmp1 = p1 + a / d * (p2-p1);
  P tmp2 = h / d * (p2-p1);

  if(abs(tmp2) < EPS) res.push_back(tmp1);
  else {
    res.push_back(P(real(tmp1) - imag(tmp2), imag(tmp1) + real(tmp2)));
    res.push_back(P(real(tmp1) + imag(tmp2), imag(tmp1) - real(tmp2)));
  }
  return res;
}


int n;
vector<P> v;

int solve(){
  int ans = 1;

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      vector<P> cc = getIntersectCC(Circle(v[i], R), Circle(v[j], R)); // v[i]??¨v[j]??????????????¢?????¨??????R??¨????????? (?????´?????????????????????????????????????????????)
      if(cc.size() == 0) continue;
      for(int k=0;k<cc.size();k++){
        int res = 0;
        for(int l=0;l<n;l++) if(abs(v[l]-cc[k]) <= R + EPS) res++;
        ans = max(ans, res);
      }
    }
  }

  return ans;
}

int main(){
  while(cin >> n && n){
    v.clear();
    for(int i=0;i<n;i++){
      double x, y;
      cin >> x >> y;
      v.push_back(P(x,y));
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1272
#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;

typedef long long ll;
template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <char cmp = '<'>
    bool icmp(ll a, ll b){ if(cmp=='>') return a > b; else return a < b;}
namespace enhanced_pair{
    typedef pair<ll,ll> pll;
    ostream& operator << (ostream& o, const pll a){
        o<<a.first<<" "<<a.second;
        return o;
    }
    istream& operator >> (istream& i, pll& p){
        i>>p.first>>p.second;
        return i;
    }
    template <char cmp1 = '<', char cmp2 = '<'>
        bool pcmp(pll a, pll b){ return icmp<cmp1> (a.first,b.first) || (a.first==b.first && icmp<cmp2> (a.second,b.second));}
} using namespace enhanced_pair;
const size_t NMAX = 200009;
const ll MOD = 1e9+7;
ll lastbit(ll num){
    return num & -num;
}
ll binPow(ll num, ll p, ll mod = MOD){
    if(!p) return 1;
    ll aux = binPow(num,p/2);
    return aux*aux%mod*(p%2?num:1)%mod;
}

void tc()
{

}
int main()
{
    string a,b;
    cin>>a>>b;
    ll cnt=0;
    for(ll i=0;i<a.size();i++){
        cnt+=(a[i]!=b[i]);
    }
    cout<<cnt;
    return 0;
}



Measured memory_bytes: 3856
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    # input
    n, m = map(int, input().strip().split())

    # input and variables initialization
    dict_x = {}
    for i in range(m):
        s_temp, m_temp = map(int, input().strip().split())
        s_temp -= 1
        m_temp = str(m_temp)
        if s_temp in dict_x and dict_x[s_temp] != m_temp:
            print(-1)
            return
        else:
            dict_x[s_temp] = m_temp

    # main process
    for x in range(0 if n == 1 else 10**(n-1), 10**(n)):
        # variables initialization
        S = str(x)
        failure_flag = 0

        # for all i, if i is in dict_x then S[i] == dict_x[i]
        for i in range(n):
            if i in dict_x and S[i] != dict_x[i]:
                failure_flag = 1
            else:
                pass

        #
        if failure_flag == 0:
            print(x)
            return
        else:
            pass


    print(-1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61036
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

		int M = scanner.nextInt();

		int D = scanner.nextInt();

		int count = 0;

		for (int i = 1; i <= M; i++) {
			for (int j = 1; j <= D; j++) {
				if (i == ((j / 10) * (j % 10))
						&& (j / 10) != 1
						&& (j % 10) != 1) {
					count++;
				}
			}
		}

		log(count);

	}

	private static void log(String str) {
		System.out.println(str);
	}

	private static void log(int str) {
		System.out.println(str);
	}

	private static void log(double str) {
		System.out.println(str);
	}

}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
long n,c,a,s;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a)s+=a;
		else c+=s/2,s=0;
	}
	c+=s/2;
	cout<<c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=1e5;

int n,ans;
string str;

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	cin>>str;
	for(int i=0;i<n;i++){
		while(i<n-1 && str[i]==str[i+1])i++;
		ans++;
	}
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  vector<pint> data;
  int N; cin>>N;
  REP(i,N) {
    int a; cin>>a;
    data.push_back(make_pair(a, i+1));
  }
  sort(data.begin(), data.end());
  REP(i,N) {
    if(i > 0) cout << " ";
    cout << data[i].second ;
  }
  cout << endl;
  return 0;
}


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

using namespace std;

int main() {
  int N, K, cnt = 0;
  
  cin >> N >> K;
  
  while (N > 0) {
    if (cnt == 0) {
      N -= K;
    } else {
      N -= K - 1;
    }
    
    cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{

    int n;
    cin>>n;

    int a[n];

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

    int flag = 1;
    
    int maxi = INT_MIN;
    for(int i=0;i<n-1;i++){
        if(a[i] > maxi) maxi = a[i];
        if(a[i+1]+1 < maxi){
            flag = 0;
        }
    }

    if(flag == 0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int a,b,H,W;

	while(1)
	{
		scanf("%d %d",&H,&W);
		if((H==0)&&(W==0))
		{
			break;
		}
		else
		{
			for(a=1;a<=H;a++)
			{
				for(b=1;b<=W;b++)
				{
					if(a%2==0)
					{
						if(b%2==0)
						{
							printf("#");
						}
						else
						{
							printf(".");
						}
					}
					else
					{
						if(b%2==0)
						{
							printf(".");
						}
						else
						{
							printf("#");
						}
					}
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 572
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        mut k:i64
    }
    if k <= 10 {
        println!("{}", k);
        return;
    }
    //  n-1桁の数で、10^(n-1)の位がxの時、のルンルン数の合計 t は？
    // とりあえず60桁くらいまで箱を用意。
    let mut t = vec![vec![0i64; 11]; 60];
    for i in 0..10 {
        t[0][i] = 1;
    }
    k -= 9;
    for n in 1..60 {
        for i in 1..10 {
            // t[n-1][10]は常に0で初期化済み。
            //println!(":{},{},{}", k, n, i);
            let p = t[n - 1][i - 1];
            let q = t[n - 1][i];
            let r = t[n - 1][i + 1];
            t[n][i] = p + q + r;
            if k > p + q + r {
                k -= p + q + r;
                continue;
            } else {
                //println!("kni:{},{},{}", k, n, i);
                // 10^(n-1)の位がi に 確定したので...。
                println!("{}", lunlun(k, n, i, &t));
                return;
            }
        }
        t[n][0] = t[n - 1][0] + t[n - 1][1];
    }
}
fn lunlun(k: i64, n: usize, i: usize, t: &Vec<Vec<i64>>) -> i64 {
    if n == 0 {
        return i as i64;
    }
    let p = if i != 0 { t[n - 1][i - 1] } else { 0 };
    let q = t[n - 1][i];
    let r = if i != 9 { t[n - 1][i + 1] } else { 0 };
    if k <= p {
        return (i * 10usize.pow(n as u32)) as i64 + lunlun(k, n - 1, i - 1, t);
    }
    if k <= p + q {
        return (i * 10usize.pow(n as u32)) as i64 + lunlun(k - p, n - 1, i, t);
    }
    return (i * 10usize.pow(n as u32)) as i64 + lunlun(k - p - q, n - 1, i + 1, t);
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

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

  ll w = 0;
  ll r = 0;
  ll c = 0;
  for (int i=0; i<n; i++) {
    if (s[i] == 'W') w++;
    else {
      r++;
      if (w>0) c++;
    }
  }
  ll ans = min(w, c);

  ll cnt = 0;
  ll left = 0;
  ll right = n-1;
  while (left < right) {
    if (s[left] == 'W') {
      if (s[right] == 'R') {
        cnt++; left++;
      }
      right--;
    } else {
      left++;
      if (s[right] == 'W') right--;
    }
  }
  ans = min(ans, cnt);
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3656
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

		int x = a + b;
        if(x%2 == 1){
            System.out.println((x+1)/2);
        } else{
            System.out.println(x/2);
        }
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <set>
using namespace std;

const int inf = 1e+9;

string s;
vector<int> path;

vector<int> t, ind;

void build(int v, int tl, int tr)
{
	if (tl == tr)
	{
		t[v] = 0;
		ind[v] = tl;
		
		if (s[tl] == '1')
		{
			t[v] = inf;
			ind[v] = -1;
		}
		return;
	}


	int tm = (tl + tr) >> 1, lc = (v << 1), rc = (v << 1) + 1;
	build(lc, tl, tm);
	build(rc, tm + 1, tr);

	if (t[lc] < t[rc])
	{
		t[v] = t[lc];
		ind[v] = ind[lc];
	}
	else
	{
		t[v] = t[rc];
		ind[v] = ind[rc];
	}

	if (t[lc] == t[rc])
	{
		if (ind[lc] < ind[rc])
		{
			t[v] = t[lc];
			ind[v] = ind[lc];
		}
		else
		{
			t[v] = t[rc];
			ind[v] = ind[rc];
		}
	}
}

void update(int v, int tl, int tr, int pos, int val)
{
	if (tl == tr)
	{
		t[v] = val;
		return;
	}

	int tm = (tl + tr) >> 1, lc = (v << 1), rc = (v << 1) + 1;
	if (pos <= tm)
	{
		update(lc, tl, tm, pos, val);
	}
	else
	{
		update(rc, tm + 1, tr, pos, val);
	}

	if (t[lc] < t[rc])
	{
		t[v] = t[lc];
		ind[v] = ind[lc];
	}
	else
	{
		t[v] = t[rc];
		ind[v] = ind[rc];
	}

	if (t[lc] == t[rc])
	{
		if (ind[lc] < ind[rc])
		{
			t[v] = t[lc];
			ind[v] = ind[lc];
		}
		else
		{
			t[v] = t[rc];
			ind[v] = ind[rc];
		}
	}
}

pair<int, int> get(int v, int tl, int tr, int l, int r)
{
	if (l > r)
	{
		return make_pair(inf, -1);
	}

	if (tl == l && tr == r)
	{
		return make_pair(t[v], ind[v]);
	}

	int tm = (tl + tr) >> 1, lc = (v << 1), rc = (v << 1) + 1;

	pair<int, int> p1, p2;
	p1 = get(lc, tl, tm, l, min(r, tm));
	p2 = get(rc, tm + 1, tr, max(tm + 1, l), r);
	//return make_pair(inf, -1);
	pair<int, int> p;
	if (p1.first < p2.first)
	{
		p.first = p1.first;
		p.second = p1.second;
	}
	else
	{
		p.first = p2.first;
		p.second = p2.second;
	}

	if (p1.first == p2.first)
	{
		if (p1.second < p2.second)
		{
			p.first = p1.first;
			p.second = p1.second;
		}
		else
		{
			p.first = p2.first;
			p.second = p2.second;
		}
	}

	return p;
}

vector<int> ans;

void print(int k, int n)
{
	for (int i = 0; i <= k; i++)
	{
		cout << get(1, 0, n, i, i).first << " ";
	}
	cout << "\n";
}

void solve()
{
	int n, m;
	cin >> n >> m >> s;

	path.assign(n + 1, -1);
	t.resize(4 * (n + 1));
	ind.resize(4 * (n + 1));


	build(1, 0, n);

	for (int i = 1; i <= n; i++)
	{
		if (s[i] == '1')
		{
			continue;
		}

		pair<int, int> p = get(1, 0, n, max(0, i - m), i - 1);

		//cout << p.first << " " << p.second << "\n";
		path[i] = p.second;
		if (p.first != inf)
		{
			update(1, 0, n, i, p.first + 1);
		}

		//print(i, n);cout << "\n";
	}

	int cur = n;
	while (cur != 0)
	{
		if (path[cur] == -1)
		{
			cout << -1;
			return;
		}

		ans.push_back(abs(cur - path[cur]));
		cur = path[cur];
	}

	reverse(ans.begin(), ans.end());

	for (int i = 0; i < (int)ans.size(); i++)
	{
		cout << ans[i] << " ";
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4684
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int n;
	cin>>n;
	ll int d=n/1000;
	if (n%1000!=0)
	{
	
	ll int r=(d+1)*1000-n;
	cout<<r<<endl;
}
else
cout<<0<<endl;
	
}
	
		
	
	
	
	




Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n, k;
	scanf("%d%d", &n, &k);
	vi v(n);
	for (int i = 0; i < n; i++) scanf("%d", &v[i]);

	int r = min(n, k);
	int ans = -1e9;
	for (int a = 0; a <= r; a++) {
		for (int b = 0; b <= r - a; b++) {
			vi tmp(v.begin(), v.begin() + a);
			for (int i = 0; i < b; i++) tmp.push_back(v[n-1-i]);
			sort(all(tmp));
			int c = k - a - b;
			int i;
			for (i = 0; i < tmp.size() && i < c; i++) {
				if (tmp[i] >= 0) break;
			}

			int cur = 0;
			for (; i < tmp.size(); i++) cur += tmp[i];
			ans = max(ans, cur);
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

K, N = LI()
A = LI()

ans = mod
diff = [0 for i in range(N)]
for i in range(N - 1):
    diff[i] = A[i + 1] - A[i]
diff[-1] = (K - A[-1]) + A[0]
# print(diff)
ans = K - max(diff)
print(ans)

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    int n, k;
    cin >> n >> k;
    vec<ll> p(n), c(n);
    REP(i, n) {
        cin >> p[i];
        p[i]--;
    }
    REP(i, n) {
        cin >> c[i];
    }

    ll ans = -INF;
    vec<bool> used(n, false);
    vec<ll> scores;
    auto dfs = [&](auto &&self, int v) -> void {
        used[v] = true;
        scores.push_back(c[v]);
        if(used[p[v]])
            return;
        self(self, p[v]);
    };
    REP(i, n) {
        if(used[i])
            continue;
        scores.clear();
        dfs(dfs, i);
        int m = scores.size();
        vec<ll> sum(2 * m + 1, 0);
        REP(i, 2 * m) {
            sum[i + 1] = sum[i] + scores[i % m];
        }
        ll ma = -INF;

        REP(i, m) {
            rep(j, i + 1, i + m + 1) {
                ll tmp = 0;
                ll t = k - j + i;
                if(t < 0)
                    continue;
                if(t >= m and sum[m] > 0)
                    tmp += t / m * sum[m];
                chmax(ma, tmp + sum[j] - sum[i]);
                //cout << i << " " << j << " " << tmp + sum[j] - sum[i] << " " << sum[m] << en;
            }
        }
        //cout << i << " " << ma << en;
        chmax(ans, ma);
    }
    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3808
#include <array>
#include <string>
#include <iostream>
int main()
{
    std::array<std::string, 2> name;
    std::cin >> name[0] >> name[1];
    std::array<std::size_t, 2> count;
    std::cin >> count[0] >> count[1];
    std::string selected;
    std::cin >> selected;
    --count[(selected == name[1])];
    std::cout << count[0] << ' ' << count[1] << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    if(a+b==3){
        printf("3\n");
    }
    else if(a+b==4){
        printf("2\n");
    }
    else{
        printf("1\n");
    }
    return 0;
}

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

#define ll long long
#define pb push_back

using namespace std;

int main()
{
    ll n, i, j, a, b;
    string s = "NG\n";

    cin >> n >> a >> b;

    for(i = 1; ; i++) {
        j = n * i;
        if(j >= a) {
            if(j <= b)
                s = "OK\n";
            break;
        }
    }


    cout << s;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<ll> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	for(int i = k; i < n; ++i) {
		if( a[i] > a[i - k] ) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}


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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  cin >> a;
  vector<ll> res(n, inf + 1);
  for(int i = 0; i < n; i++){
    *lower_bound(all(res), a[i]) = a[i];
  }
  cout << lower_bound(all(res), inf) - res.begin() << endl;
	return 0;
}



Measured memory_bytes: 4428
import sys
sys.setrecursionlimit(10**5)
s = input()
t = input()

#dp[i][j] => s[i], t[j]までの最長部分文字列

dp = [[0] * (len(t) + 1) for j in range(len(s) + 1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1] == t[j-1]:
            x = 1
        else:
            x = 0
        dp[i][j] = max(dp[i-1][j-1] + x, dp[i-1][j], dp[i][j-1])


def make_ans(a, b):
    if a ==  0 or b == 0:
        return 
    if s[a-1] == t[b-1]:
        make_ans(a-1,b-1)
        ans.append(s[a-1])
    else:
        if a == 0:
            make_ans(a, b - 1)
        elif b == 0:
            make_ans(a - 1,b)
        else:
            if dp[a - 1][b] > dp[a][b - 1]:
                make_ans(a-1,b)
            else:
                make_ans(a,b-1)

ans = []
make_ans(len(s),len(t))
print("".join(ans))

Measured memory_bytes: 117468
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
typedef long long int llint;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 1;i < n;i++) {
		if (a[i] == a[i - 1]) {
			a[i]++;
			if (a[i] == a[i + 1]) {
				a[i]++;
			}
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll a, b;
  cin >> a >> b;
  bool judge;
  ll result;
  vector<ll> p(999);
  p[0] = 1;
    
  for(i = 1; i < 999; i++)
    p[i] = p[i - 1] + i + 1;
  
  cout << p[b - a - 1] - b << endl;  

  /*
  vector<ll> a(n);
  for(i = 0; i < n; i++)
    cin >> a[i];
  //for(i = 0; i < n; i++)
    
  */
  
  
  /*if(judge)
    cout << "ABC" << endl;
    //cout << "YES" << endl;
    //cout << "Yay!" << endl;
  else
    cout << "ABD" << endl;
    //cout << "NO" << endl;
    //cout << ":(" << endl;
  */
  
  
  //cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

//         d   w  x
int memo[32][64][8];


int main(){
  while(true){
    const int c = getInt();
    const int d = getInt();
    const int w = getInt();
    const int x = getInt();

    if(c + d + w + x == 0) break;

    vector<vector<int> > e(d, vector<int>(c));
    vector<vector<int> > f(d, vector<int>(c));

    REP(i,c) REP(j,d) e[j][i] = getInt();
    REP(i,c) REP(j,d) f[j][i] = getInt();

    REP(i,d + 1) REP(j, w + 1) REP(k, x + 1)
      memo[i][j][k] = -1;

    memo[0][0][0] = 0;

    REP(i,d) REP(j,w + 1) REP(k, x + 1){
      if(memo[i][j][k] != -1){
        memo[i + 1][j][k] = max(memo[i + 1][j][k], memo[i][j][k]);
        REP(p, c) if(e[i][p] != 0 && f[i][p] + j <= w)
          memo[i + 1][f[i][p] + j][k] = max(memo[i + 1][f[i][p] + j][k],
                                            memo[i][j][k] + e[i][p]);
        if(k != x)
          for(int st = 0; st < c; st++)
            if(e[i][st] != 0){
              for(int ed = st + 1; ed < c && e[i][ed] != 0; ed++){
                int es = memo[i][j][k];
                int ws = j;
                for(int p = st; p <= ed; p++){
                  es += e[i][p];
                  ws += f[i][p];
                }
                if(ws <= w){
                  memo[i + 1][ws][k + 1] = max(memo[i + 1][ws][k + 1], es);
                }
              }
            }
      }
    }

    int ans = 0;
    REP(i, w + 1) REP(j, x + 1) ans = max(ans, memo[d][i][j]);
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
main()
{
  int a, b, c ,i ;
  int j = 0;
  scanf("%d %d %d",&a, &b, &c);
  for(i=a;i<=b;i++){
    if(c%i==0)
      ++j ;}
  printf("%d\n",j);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
using namespace std;

int main()
{
	int x[4],y[4];
	int dif_x,dif_y;

	cin >> x[0] >> y[0] >> x[1] >> y[1];

	dif_x = x[1] - x[0];
	dif_y = y[1] - y[0];

	x[2] = x[1]-dif_y;
	y[2] = y[1]+dif_x;

	x[3] = x[0]-dif_y;
	y[3] = y[0]+dif_x;

	for (int i = 2; i < 4; i++) {
		std::cout  << x[i] << " " << y[i] << " ";
	}
	std::cout  << '\n';

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

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

      long x1 = 1_000_000_000;

      long y2 = (s + x1 - 1) / x1;

      long x2 = 1;

      long y1 = x1 * y2 - s;

      System.out.println("0 0" + " " + x1 + " " + y1 + " " + x2 + " " + y2);
  }
}

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

signed main() {
	int a, b;
	cin >> a >> b;
	string c[100];
	for (int d = 0; d < a; d++) {
		string e;
		cin >> e;
		c[d] = e;
	}
	sort(c, c + a);
	for (int f = 0; f < a; f++) {
		cout << c[f];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define f first
#define s second
using namespace std;
typedef pair<int,int>par;
typedef pair<int,par>pr;
unordered_map<int,vector<int>>nod[1000005];
vector<par>nd[1000005];
unordered_map<int,int> val[1000005];
int vl[1000005];
unordered_set<int> iq[1000005];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        vl[i]=0x7fffffff;
    for(int i=0;i<m;i++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);a--;b--;
        nod[c][a].push_back(b);
        nd[a].push_back(par(b,c));
        nod[c][b].push_back(a);
        nd[b].push_back(par(a,c));
        }
    queue<par>qu;
    vector<int>q2;
    qu.push(par(0,0));
    val[0][0]=0;
    int prev=-1;
    while(!qu.empty()||!q2.empty()){
        if(!qu.empty()){
            par now=qu.front();
            qu.pop();
            int v=val[now.f][now.s];
            //printf("%d %d\n",now.f,now.s,v);
            if(now.f==n-1){
                printf("%d\n",v);
                return 0;
                }
            if(v!=prev){
                sort(q2.begin(),q2.end());
                q2.resize(unique(q2.begin(),q2.end())-q2.begin());
                while(!q2.empty()){
                    int now=q2.back();
                    q2.pop_back();
                    int v=prev;
                    for(par &x:nd[now]){
                        if(iq[x.f].find(x.s)!=iq[x.f].end())continue;
                        if(vl[x.f]>v&&val[x.f].find(x.s)==val[x.f].end()||val[x.f][x.s]>v+1){
                            val[x.f][x.s]=v+1;
                            vl[x.f]=min(vl[x.f],v+1);
                            qu.push(par(x.f,x.s));
                            }
                        }
                    }
                prev=v;
                }
            if(nod[now.s].find(now.f)!=nod[now.s].end())
                for(int x:nod[now.s][now.f]){
                    if(iq[x].find(now.s)!=iq[x].end())continue;
                    if(vl[x]>=v&&val[x].find(now.s)==val[x].end()||val[x][now.s]>v){
                        val[x][now.s]=v;
                        vl[x]=min(vl[x],v);
                        qu.push(par(x,now.s));
                        }
                    }
            q2.push_back(now.f);
            }
        else{
            sort(q2.begin(),q2.end());
            q2.resize(unique(q2.begin(),q2.end())-q2.begin());
            while(!q2.empty()){
                int now=q2.back();
                q2.pop_back();
                int v=prev;
                for(par &x:nd[now]){
                    if(iq[x.f].find(x.s)!=iq[x.f].end())continue;
                    if(vl[x.f]>v&&val[x.f].find(x.s)==val[x.f].end()||val[x.f][x.s]>v+1){
                        val[x.f][x.s]=v+1;
                        vl[x.f]=min(vl[x.f],v+1);
                        qu.push(par(x.f,x.s));
                        }
                    }
                }
            }
        }
    puts("-1");
    }


Measured memory_bytes: 249088