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

public class Main {

    public static class food implements Comparable<food> {
        int time;
        int wait;
        public food(int time, int wait) {
            this.time = time;
            this.wait = wait;
        }
        @Override
        public int compareTo (food o) {
            return this.wait-o.wait;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        food[] arr = new food[5];
        for (int i=0; i<5; i++) {
            int N = sc.nextInt();
            int T = N;
            if (N % 10 != 0) {
                T = (10 - T % 10);
            } else {
                T = 0;
            }
            arr[i] = new food(N, T);
        }
        Arrays.sort(arr);
        int counter = 0;
        int time = 0;
        while (true) {
            if (time%10==0 || time==0) {
                time += arr[counter].time;
                counter++;
                if (counter>4) {
                    System.out.println(time);
                    return;
                }
                continue;
            }
            time++;
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int a[100010];
signed main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int>q;

    REP(i,n) {
        cin>>a[i];
        q.push(a[i]);
    }
    for (int i = 0; i < m; i++)
    {
        int x=q.top();
        q.pop();
        x/=2;
        q.push(x);
    }
    ll sum=0;
   while(!q.empty()){
       sum+=q.top();
    //   cerr<<q.top()<<endl;
       q.pop();
   }
   cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1912
//PseudoName

	#pragma GCC optimize("O3")
	#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace std;
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


	#define FOR(i,n) for(i=0;i<n;i++)
	#define FOR1(i,n) for(i=1;i<=n;i++)
	#define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
	#define pb push_back
	#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
	#define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
	#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
	#define endl "\n"
	#define min3(a,b,c) min(a,min(b,c))
	#define forr(n) for(int i=0;i<n;i++)
	#define frr(n) for(int i=1;i<=n;i++)
	#define rep(i,a,b) for(int i=a;i<=b;i++)



	typedef long long ll;
	typedef long li;
	typedef vector<int> vi;
	typedef vector<ll> vli;
	typedef vector<vi> vvi;
	typedef vector<vli> vvli;
	typedef pair<int,int> pi;
	typedef pair<ll,ll> pli;
	typedef vector<pi> vpi;
	typedef vector<pli> vpli;



	//const ll MOD=1e9+7;

	/*
	ll fast_exp(ll base, ll exp) {
	    ll res=1;
	    while(exp>0) {
	       if(exp%2==1) res=(res*base)%MOD;
	       base=(base*base)%MOD;
	       exp/=2;
	    }
	    return res%MOD;
	}
	ll imod(ll a)
	{
		return fast_exp(a, MOD-2);
	}
	*/

	int main() {
	    fast();
	    ll n,m;
	    cin>>n>>m;
	    ll l;
	    ll sum=0;
	    forr(m)
	    {
	        cin>>l;
	        sum+=l;
	    }
	    if(n>=sum)
	    cout<<n-sum<<endl;
	    else
            cout<<-1<<endl;


	}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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 (a > b) {
    a = b;
    return true;
  }
  return false;
}
// O( ( |V| + |E| ) * log|V| )
const int W = 0, B = 1;
//重み付き有効グラフの隣接リスト表現
vector<int> dijkstra(const vector<vector<pair<int, int>>> &g, int s) {
  int n = g.size();
  priority_queue<pair<int, int>> pq; // cost, node
  vector<int> color(n, W), d(n, INF);
  d[s] = 0;
  pq.push(make_pair(0, s));

  while (!pq.empty()) {
    pair<int, int> f(pq.top());
    pq.pop(); // d[v], v
    color[f.second] = B;

    if (d[f.second] < (-1) * f.first)
      continue; // 最小値を取り出し、それが最短でなければ無視

    rep(i, 0, g[f.second].size()) {
      pair<int, int> v(g[f.second][i]);
      if (color[v.first] != B && d[f.second] + v.second < d[v.first]) {
        d[v.first] = d[f.second] + v.second;
        pq.push(make_pair(
            d[v.first] * (-1),
            v.first)); // priority_queueはデフォルトで大きい値を優先するため-1を掛ける
      }
    }
  }
  return d;
}
/*
signed main() {
        int n;
        cin >> n;
        vector<vector<pair<int, int>>> adj(n, vector<pair<int, int>>()); //
node, cost
        rep(i, 0, n) {
                int u, k; cin >> u >> k;
                rep(j, 0, k) {
                        int v, c; cin >> v >> c;
                        // vは頂点の番号、cは有効辺の重み
                        adj[u].push_back(make_pair(v, c));

                }
        }
        auto dijkstra(adj);
        return 0;
}
*/
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int n, m;
  cin >> n >> m;
  int s, t;
  cin >> s >> t;
  s--, t--;
  vector<vector<pair<int, int>>> en(n, vector<pair<int, int>>()); // node, cost
  vector<vector<pair<int, int>>> sunuk(n,
                                       vector<pair<int, int>>()); // node, cost
  loop(m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    en[u].push_back(make_pair(v, a));
    en[v].push_back(make_pair(u, a));
    sunuk[u].push_back(make_pair(v, b));
    sunuk[v].push_back(make_pair(u, b));
  }

  int money = 1000000000000000ll;
  auto d1 = dijkstra(en, s);
  auto d2 = dijkstra(sunuk, t);
  priority_queue<pair<int, int>> pq;
  rep(i, 0, n) { pq.push(make_pair(money - (d1[i] + d2[i]), i)); }
  dump(pq);
  rep(i, 0, n) {
    while (pq.top().second < i) {
      pq.pop();
    }
    cout << pq.top().first << endl;
  }

  return 0;
}


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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  int64_t cnt = 0;
  int64_t times = N / (A + B);
  int64_t surplus = N % (A + B);
  cout << times * A + min(surplus, A) << endl;
}


Measured memory_bytes: 256
import math
n = int(input())
x = n * (n + 1) / 2
f = math.floor(n / 3)
fizzsum = f * (f + 1) / 2 * 3
b = math.floor(n / 5)
buzzsum = b * (b + 1) / 2 * 5
fb = math.floor(n / 15)
fizzbuzzsum = fb * (fb + 1) / 2 * 15
print(int(x - fizzsum - buzzsum + fizzbuzzsum))

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

int main(){
  long long a,b; cin >>a >>b; set<int>s;
  long long c=__gcd(a,b),m=2;
  while(c>=m*m)
  {
    if(c%m==0){s.insert(m); c/=m;}
    else m++;
  }
  s.insert(c); s.insert(1);
  cout <<s.size();
return 0;}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int64 minsq(int64 x){ // x個を正方形内に入れる最小の正方形9 -> 3, 10 -> 4
	int64 a = sqrt(x);
	if(a*a >= x) return a;
	return a+1;
}

int main(void){
	int32 N, D;
	cin >> N >> D;
	vector<int64> x(N), y(N);
	REP(i, N) cin >> x[i] >> y[i];
	vector<vector<int32>> cnt(3030, vector<int32>(3030, 0));
	vector<vector<int32>> ok1(3030, vector<int32>(3030, 0));
	vector<vector<int32>> ok2(3030, vector<int32>(3030, 0));
	int64 d = 0;
	REP(i, N){
		cnt[x[i]%D][y[i]%D]++;
		chmax(d, cnt[x[i]%D][y[i]%D]);
	}
	using T = tuple<int64, int64, int64>;
	vector<T> v;
	sort(all(v), greater<T>());
	d = minsq(d);
	REP(i, D){
		REP(j, D){
			REP(k, 3){
				REP(l, 3){
					if(cnt[i][j] > (d-1)*(d-1)) ok1[i+D*k][j+D*l]++;
					if(cnt[i][j] > d*(d-1)) ok2[i+D*k][j+D*l]++;
				}
			}
		}
	}
	REP(i, 3*D){
		REP(j, 3*D){
			ok1[i][j+1] += ok1[i][j];
			ok2[i][j+1] += ok2[i][j];
		}
	}
	REP(j, 3*D){
		REP(i, 3*D){
			ok1[i+1][j] += ok1[i][j];
			ok2[i+1][j] += ok2[i][j];
		}
	}
	auto sum1 = [&](int32 x1, int32 y1, int32 x2, int32 y2){
		int32 res = ok1[x2][y2];
		if(x1 > 0) res -= ok1[x1-1][y2];
		if(y1 > 0) res -= ok1[x2][y1-1];
		if(x1 > 0 && y1 > 0) res += ok1[x1-1][y1-1];
		return res;
	};
	auto sum2 = [&](int32 x1, int32 y1, int32 x2, int32 y2){
		int32 res = ok2[x2][y2];
		if(x1 > 0) res -= ok2[x1-1][y2];
		if(y1 > 0) res -= ok2[x2][y1-1];
		if(x1 > 0 && y1 > 0) res += ok2[x1-1][y1-1];
		return res;
	};
	int32 l = -1, r = D+1, m;

	auto ok = [&](int32 b){
		REP(x, D){
			REP(y, D){
				bool ok = 1;
//				cout << x << " " << y << " " << b << endl;
//				cout << sum1(x, y+b+1, x+b, y+D-1) << " " << sum1(x+b+1, y, x+D-1, y+b) << " " << sum2(x+b+1, y+b+1, x+D-1, y+D-1) << endl;
				if(sum1(x+b+1, y+b+1, x+D-1, y+D-1) > 0) ok = 0;
				if(sum2(x+b+1, y, x+D-1, y+b) > 0) ok = 0;
				if(sum2(x, y+b+1, x+b, y+D-1) > 0) ok = 0;
				if(ok) return 1;
			}
		}
		return 0;
	};

	while(r-l > 1){
		m = (l+r)/2;
		if(ok(m))
			r = m;
		else
			l = m;
	}
	cout << (d-1)*D+r << endl;
}


Measured memory_bytes: 217344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair <int,int> ii ;
typedef vector < ii > vii ;
typedef vector < vii > viii ;
#define rep(i,n)                   for( ll i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++) 
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define db double 
#define fi first
#define se second
const ll mod =1000000007;

int main() {
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	int n,k; cin>>n>>k;
  	int a[n];
  	repu(i,1,n) cin>>a[i];
  	//sort(a,a+n);
  	int dp[1000000];
  	memset(dp,0,sizeof dp);
  	repu(i,1,k) {
  		repu(j,1,n) {
  			if(a[j]<=i) {
  				if(!dp[i-a[j]]) dp[i]=1;
  			}
  		}
  	}
  	if(dp[k]) cout<<"First"<<endl;
  	else cout<<"Second"<<endl;
}

Measured memory_bytes: 4352
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();
		String[] s = new String[h];
		int[] dx = { -1, 0, 1, -1, 1, -1, 0, 1 };
		int[] dy = { -1, -1, -1, 0, 0, 1, 1, 1 };

		for (int i = 0; i < h; i++) {
			s[i] = sc.next();
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i].charAt(j) == '#') {
					System.out.print('#');
					continue;
				}

				int num = 0;
				for (int d = 0; d < 8; d++) {
					int ni = i + dx[d];
					int nj = j + dy[d];

					if (ni < 0 || h <= ni) {
						continue;
					}
					if (nj < 0 || w <= nj) {
						continue;
					}

					if (s[ni].charAt(nj) == '#') {
						num++;
					}
				}

				System.out.print(num);
			}
			System.out.println();
		}
	}
}

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

#[fastout]
fn main() {
    input! {
        n_str: String,
    };
    let acc: i64 = n_str
        .chars()
        .fold(0, |acc, c| c.to_digit(10).unwrap() as i64 + acc);
    println!("{}", if acc % 9 == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 2400
#include<stdio.h>
#define Number 100000
int main()
{
	int n;
	int c=0;
	int Sel[Number];
	int i ,j ,minj ,z;
	int temp;


	scanf("%d",&n);

	for(i=0;i<=n-1;i++)
	{
		scanf("%d",&Sel[i]);
	}

	for(i=0;i<=n-1;i++)
	{
		minj=i;
		for(j=i;j<=n-1;j++)
		{
			if (Sel[j] < Sel[minj])
			{	
				minj=j;
			}	
		}
		if(minj!=i)
		{
		temp=Sel[minj];
		Sel[minj]=Sel[i];
		Sel[i]=temp;	
		c++;
		
	    }
	}

		for(z=0;z<n-1;z++)
	{
		printf("%d ",Sel[z]);
	}
		printf("%d\n",Sel[n-1]);
	printf("%d\n",c);

	}


Measured memory_bytes: 1928
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;

const int MAXN = 100010;

int a[MAXN],b[MAXN];

long long update(long long next,long long a,long long b){
  long long x = (a / b) * b - a;
  if(x < 0) x+=b;
  if(x < next) {
    x = next;
    if((x+a) % b > 0)
      x = x + (b - (x+a) % b);
  }
  return x;
}

int main(){
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++)
    scanf("%d%d",&a[i],&b[i]);
  long long ans = 0;
  for(int i = n; i >= 1; i--) ans = update(ans,a[i],b[i]);
  cout << ans;
  return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, q = map(int, input().split())

graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)

values = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    values[p-1] += x

def dfs(v1, parent, add):
    values[v1] += add
    for v2 in graph[v1]:
        if v2 == parent:
            continue
        dfs(v2, v1, values[v1])

dfs(0, 0, 0)
print(*values)

Measured memory_bytes: 230960
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int isprime(int n)
{
    for(int i=2;i<=sqrt(n);++i)
    {
        if(n%i==0) return 0;
    }
    return 1;
}

lli mlkfs(lli n)
{
    if(n>1) return 2*mlkfs(n/2)+1;
    if(n==1) return 1;
}

int main()
{
    fastio();
    lli n,j; cin>>n>>j; for(int i=1;i<n;++i) {lli k; cin>>k; j=gcd(j,k);}
    lli count=0;
    while(j%2==0)
    {
        j>>=1; ++count;
    }
    cout<<count;
    return 0;
}

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

Measured memory_bytes: 1852
#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 N;
    cin >> N;
    int sum=0;
    rep(i,N)sum+=i+1;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define INF (int)1e9

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

string A, B;
int dp[3001][3001];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> A >> B;
	A = " " + A;
	B = " " + B;
	for(int i = 0; i < (int)A.length(); i++)
		for(int j = 0; j < (int)B.length(); j++)
			if(i == 0 || j == 0) dp[i][j] = 0;
			else if(A[i] == B[j]) dp[i][j] = 1 + dp[i - 1][j - 1];
			else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
	int i = (int)A.length() - 1, j = (int)B.length() - 1;
	string str;
	while(i != 0 && j != 0)
		if(A[i] == B[j]) str.insert(str.begin(), A[i]), i--, j--;
		else if(dp[i - 1][j] > dp[i][j - 1]) i--;
		else j--;
	cout << str << "\n";
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    ll ans = 0;
    for(int a=1;a<n;a++){
        for(int b=1;a*b<n;b++){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <cstdio>

int a[501][501], k;

int main() {
	scanf("%d", &k);
	int n = k;
	if(n > 500) n = 500;
	printf("%d\n", n);
	for(int i = 1; i <= n; ++ i)
	for(int j = 1; j <= n; ++ j)
		a[i][j] = (i + j) % n + 1;
	for(int i = 1; i <= k-n; ++ i)
		for(int j = 1; j <= n; j += 2)
			a[j][(i+n-j)%n+1] = i + n;
	for(int i = 1; i <= n; ++ i, putchar(10))
	for(int j = 1; j <= n; ++ j)
		printf("%d ", a[i][j]);
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    long long int n,sum=0;
    cin>>n;
    rep(i,n-1){
        sum+=i+1;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    int a,x,y;
    priority_queue<int, vector<int>, greater<int>> Ap;
    priority_queue<int> An;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        if ( a >= 0 ) Ap.push(a);
        else An.push(a);
    }
    vector<pair<int, int>> nums;
    if ( Ap.size() == 0 ) {
        Ap.push(An.top());
        An.pop();
    } else if ( An.size() == 0 ) {
        An.push(Ap.top());
        Ap.pop();
    }
    while ( Ap.size() > 1 ) {
        x = Ap.top();
        Ap.pop();
        y = An.top();
        An.pop();
        An.push(y-x);
        nums.push_back(make_pair(y,x));
    }
    while ( An.size() > 1 ) {
        x = Ap.top();
        Ap.pop();
        y = An.top();
        An.pop();
        Ap.push(x-y);
        nums.push_back(make_pair(x,y));
    }
    x = Ap.top();
    Ap.pop();
    y = An.top();
    An.pop();
    int ans = x-y;
    nums.push_back(make_pair(x,y));
    
    cout << ans << '\n';
    for ( int i = 0; i < N-1; i++ ) {
        cout << nums[i].first << " " << nums[i].second << "\n";
    }
    return 0;
}

Measured memory_bytes: 3316
N = int(input())
CSF = [[] for T in range(0,N-1)]
for TN in range(0,N-1):
    CSF[TN] = [int(T) for T in input().split()]
for TN in range(0,N):
    Time = 0
    for TT in range(TN,N-1):
        if Time>=CSF[TT][1]:
            Time += CSF[TT][0] + (CSF[TT][2]-(Time%CSF[TT][2]))%CSF[TT][2]
        else:
            Time += CSF[TT][0] + (CSF[TT][1]-Time)
    print(Time)

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

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int m = sc.nextInt();
			int n = sc.nextInt();
			int d = sc.nextInt();

			if ((m | n | d) == 0) {
				break;
			}

			int init[][] = new int[n][m];

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					init[i][j] = sc.nextInt();
				}
			}

			int push[][][][] = new int[n][m][n][m];

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

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {

					push[i][j][i][j] = 1;

					for (int z = 0; z < 4; z++) {
						for (int k = 0; k <= d; k++) {
							int ni = dx[z] * k + i;
							int nj = dy[z] * (d - k) + j;

							if (ni < n && ni >= 0) {
								if (nj < m && nj >= 0) {
									push[i][j][ni][nj] = 1;
								}
							}
						}
					}
				}
			}
		

			boolean ng = false;

			boolean used[][] = new boolean[n][m];

			for (int i = 0; i < n && !ng; i++) {
				for (int j = 0; j < m && !ng; j++) {
					int y = 0;
					int x = 0;
					boolean kkks = false;
					for (y=0; y < n; y++) {
						for (x=0; x < m; x++) {
							if (used[y][x]) {
								continue;
							}
							if (push[y][x][i][j] == 1) {
								kkks = true;
								break;
							}
						}
						if (kkks) {
							break;
						}
					}

					
					if (y == n) {
						if (init[i][j] == 1) {
					//		System.out.println(i +" " + j + " fjsaoi");
							ng = true;
							break;
						} else {
							continue;
						}
					}
					

					used[y][x] = true;

					for (int zi = 0; zi < n; zi++) {
						for (int zj = 0; zj < m; zj++) {
							if (zi == y && zj == x) {
								continue;
							}
							if (push[zi][zj][i][j] == 1) {
								for (int z1 = 0; z1 < n; z1++) {
									for (int z2 = 0; z2 < m; z2++) {
										push[zi][zj][z1][z2] = push[y][x][z1][z2]
												^ push[zi][zj][z1][z2];
									}
								}
							}
						}
					}

					if (init[i][j] == 1) {
						for (int z1 = 0; z1 < n; z1++) {
							for (int z2 = 0; z2 < m; z2++) {
								init[z1][z2] = init[z1][z2]
										^ push[y][x][z1][z2];
							}
						}
					}

				}
			}
/*			
			for(int i =0; i < n ; i++){
				for(int j = 0; j < m ; j++){
					System.out.println("-----------\n"+i+" "+j);
					for(int k = 0; k < n ; k++){
						for(int l = 0 ; l < m ; l++){
							System.out.print(push[i][j][k][l]+" ");
						}	
						System.out.println();
						
						
					}
				}
						
			}
		*/	
			
			if (ng) {
				System.out.println(0);
			} else {
				System.out.println(1);
			}
		}
	}

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

Measured memory_bytes: 0
s1,s2,s3,s4 = list(input())
p=0
if s1==s2 and s2== s3 and s3==s4:
    p=1
elif s1==s2:
    if s3!=s4:
        p=1
elif s1==s3:
    if s2!=s4:
        p=1
elif s1==s4:
    if s3!=s2:
        p=1
else:
    p=1
if p==0:
    print("Yes")
elif p==1:
    print("No")


Measured memory_bytes: 9108
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<bits//stdc++.h>
#include<functional>
using namespace std;
int d[1000],c[1000];
int memo[1000][1000];
int n,m;
int solve(int i,int j){
	if(i==n){
		return 0;
	}
	else if(n-i==m-j){
		if(memo[i+1][j+1]==-1) memo[i+1][j+1]=solve(i+1,j+1);
		return c[j]*d[i]+memo[i+1][j+1];
	}
	else{
		int res1,res2;
		if(memo[i][j+1]!=-1){
			res1=memo[i][j+1];
		}
		else res1=memo[i][j+1]=solve(i,j+1);
		if(memo[i+1][j+1]!=-1){
			res2=d[i]*c[j]+memo[i+1][j+1];
		}
		else {
			res2=memo[i+1][j+1]=solve(i+1,j+1);
			res2+=(d[i]*c[j]);
		}
		return min(res1,res2);
	}
}
int main() {
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>d[i];
		for(int j=0;j<m;j++){
			memo[i][j]=-1;
		}
	}
	for(int i=0;i<m;i++)cin>>c[i];
	int ans=solve(0,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 6232
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_left(s, x), bisect.bisect_left(t, x)
  #print(b,d)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
      res = min(res, d1, d2)
  print(res)

Measured memory_bytes: 90848
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        // https://atcoder.jp/contests/abc127/submissions/5624603
        int n = in.nextInt();
        int m = in.nextInt();

        List<Integer> a = new ArrayList<>();
        for (int i=0; i < n; i++)
            a.add(in.nextInt());

        List<Map.Entry<Integer, Integer>> bc = new ArrayList<>();
        for (int i=0; i < m; i++) {
            int b = in.nextInt();
            int c = in.nextInt();
            bc.add(new AbstractMap.SimpleEntry<>(b, c));
        }
        bc.sort((o1, o2) -> o2.getValue() - o1.getValue());
        Collections.sort(a);

        int index = 0;
        for (Map.Entry<Integer, Integer> e : bc) {
            for (int i=0; i < e.getKey(); i++) {
                if (index >= a.size())
                    break;

                if (a.get(index) < e.getValue()) {
                    a.set(index, e.getValue());
                } else {
                    break;
                }

                index++;
            }
        }

        long ans = 0;
        for (int i : a)
            ans += i;
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 51568
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[1010];
int bitree[1010],l[1010],r[1010];
std::vector<int> ans;
bool use[1010],erased[1010];

int query(int x){
	int ret = 0;
	while(x){
		ret += bitree[x];
		x -= (x&-x);
	}
	return ret;
}

void update(int x, int v){
	while(x<1010){
		bitree[x] += v;
		x += (x&-x);
	}
}

void erase(int x){
	int p,q;
	p = l[x];
	q = r[x];
	l[q] = p;
	r[p] = q;
	update(x,-1);
	erased[x] = true;
}

int main(void){
	int n,i,p;
	bool flag = false;
	ll s[2]={0ll,0ll};
	std::cin >> n;
	for(i=1; i<=n; ++i){
		l[i] = i-1; r[i] = i+1; update(i,1);
		std::cin >> a[i];
		if(a[i]>=0ll){
			flag = true;
		}
		s[i%2] += std::max(a[i],0ll);
	}
	if(flag){
		p = (s[0]<s[1]);
		for(i=1; i<=n; ++i){
			use[i] = (i%2==p && a[i]>=0ll);
		}
	}else{
		s[0] = -INFLL; s[1]=-INFLL;
		for(i=1; i<=n; ++i){
			s[i%2] = std::max(s[i%2],a[i]);
		}
		p = (s[0]<s[1]);
		for(i=1; i<=n; ++i){
			if(i%2==p && a[i] == s[i%2]){
				use[i] = true;
				break;
			}
		}
	}
	std::cout << std::max(s[0],s[1]) << std::endl;
	for(i=n; i>0; --i){
		if(use[i]){
			break;
		}
		ans.push_back(query(i));
		erase(i);
	}
	for(i=1; i<=n; ++i){
		if(use[i]){
			break;
		}
		ans.push_back(query(i));
		erase(i);
	}
	use[0] = true; use[n+1] = true;
	for(i=1; i<=n; ++i){
		if(erased[i]){
			continue;
		}
		if(!(use[l[i]]||use[i]||use[r[i]])){
			ans.push_back(query(i));
			erase(l[i]); erase(r[i]);
		}
	}
	use[0] = false; use[n+1] = false;
	for(i=1; i<=n; ++i){
		if(erased[i]){
			continue;
		}
		if(use[i]){
			continue;
		}
		if(use[l[i]]&&use[r[i]]){
			ans.push_back(query(i));
			erase(l[i]); erase(r[i]);
			use[i] = true;
		}
	}
	std::cout << ans.l_ength() << std::endl;
	for(i=0; i<ans.l_ength(); ++i){
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int main(){
    for(int d; cin >> d; ){
        int ans = 0;
        for(int dd = d; dd <= 600 - d; dd += d)
          ans += d * dd * dd;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
from collections import defaultdict

def read_input():
    s = input().strip()
    return s


def submit():
    s = read_input()

    char_dic = defaultdict(int)
    for c in s:
        char_dic[c] += 1

    for item in char_dic.items():
        if item[1] % 2 == 1:
            print('No')
            return

    print('Yes')

if __name__ == '__main__':
    submit()

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

int	count_root(int N, const Graph &graph, vector<bool> &visited,
		int order, int node)
{
	if (order == N - 1)
		return 1;
	int cnt = 0;
	for (int v : graph.at(node)) {
		if (visited.at(v)) continue;
		visited.at(v) = true;
		cnt += count_root(N, graph, visited, order + 1, v);
		visited.at(v) = false;
	}
	return cnt;
}

int	main()
{
	int	N, M;
	cin >> N >> M;
	Graph	graph(N);
	int	a, b;
	for (int i = 0; i < M; ++i) {
		cin >> a >> b;
		--a, --b;
		graph.at(a).push_back(b);
		graph.at(b).push_back(a);
	}
	vector<bool>	visited(N, false);
	visited.at(0) = true;
	cout << count_root(N, graph, visited, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;



template <class T> struct Fenwick {
	int n;
	V<T> seg;
	Fenwick(int _n = 0) : n(_n), seg(n + 1) {}
	/// i番目の要素にxを追加する
	void add(int i, T x) {
		i++;
		while (i <= n) {
			seg[i] += x;
			i += i & -i;
		}
	}
	/// [0, i)のsum
	T sum(int i) {
		T s = 0;
		while (i > 0) {
			s += seg[i];
			i -= i & -i;
		}
		return s;
	}
	/// [a, b)のsum
	T sum(int a, int b) { return sum(b) - sum(a); }

	// sum[0, idx) >= xなる最小のidx(sum[0, n) < x なら n+1)
	int sum_lower_bound(T x) {
		if (x <= 0) return 0;
		int res = 0, len = 1;
		while (2 * len <= n) len *= 2;
		for (; len >= 1; len /= 2) {
			if (res + len <= n && seg[res + len] < x) {
				res += len;
				x -= seg[res];
			}
		}
		return res + 1;
	}
};


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<int, int> > res;
	Fenwick<int> ft1(N + 10);
	Fenwick<int> ft2(N + 10);
	int sum = 0;
	vector<int> T(N);
	vector<int> A(N);
	vector<int> B(N);
	vector<pair<int, int> > X;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		if (T[i] == 1) {
			cin >> A[i] >> B[i];
			X.emplace_back(A[i], i);
		}
	}

	int t = 0;
	map<pair<int, int>, int>mp;
	vector<int> rev;
	sort(X.begin(), X.end());
	for (int i = 0; i < X.size(); i++) {
		rev.push_back(X[i].first);
		mp[X[i]] = t;
		t++;

	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (T[i] == 1) {
			sum += B[i];
			int z = mp[make_pair(A[i], i)];
			ft1.add(z, 1);
			ft2.add(z, A[i]);
			cnt++;
		}
		else {
			int L = (cnt + 1) / 2;
			int idx = ft1.sum_lower_bound(L) - 1;

			int val = rev[idx] * L - ft2.sum(idx + 1);
			val += ft2.sum(idx + 1, N + 2) - rev[idx] * (cnt - L);
			res.emplace_back(rev[idx], val + sum);
		}
	}
	for (int i = 0; i < res.size(); i++) {
		cout << res[i].first << " " << res[i].second << endl;
	}
}

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

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)

int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

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

    vector<int> x(n+2); x[0]=0;
    vector<int> lx(n+1); lx[0]=0;
    rep1(i,n) cin >> x[i];

    rep1(i,n) lx[i] = abs(x[i] - m);
    
    int lx_gcd = lx[1];
    FOR(i,2,n+1) lx_gcd = gcd(lx_gcd,lx[i]);

    cout << lx_gcd << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int arr[N];
int mp[6][6];
signed main(){
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++){
			cin>>mp[i][j];
		}
	int m;
	map<int,int> vis;
	cin>>m;
	while(m--){
		int t;
		cin>>t;
	vis[t]++;
	}
	
	for(int i=1;i<=3;i++){
		int f=0;
		int f1=0;
		for(int j=1;j<=3;j++){
			f+=vis[mp[i][j]];
			f1+=vis[mp[j][i]];
		}
		if(f==3||f1==3){
			cout<<"Yes";return 0;
		}
	}
	if(vis[mp[1][1]]&&(vis[mp[2][2]]&&(vis[mp[3][3]]))){
		cout<<"Yes";return 0;
	}
	if(vis[mp[1][3]]&&(vis[mp[2][2]]&&(vis[mp[3][1]]))){
		cout<<"Yes";return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include<map>
typedef long long ll;
using namespace std;
void read(int &x){int f=1;x=0;char s=getchar();while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}x*=f;}
//void write(int x){if(x<0){putchar('-');x=-x;}if(x>9)write}
int main(){	
	int n;
	read(n);
	char s[15];
	char q;
	map<string,int>t;
	int f=1;
	scanf("%s",s);
	t[s]=1;
	q=s[strlen(s)-1];
	for(int i=1;i<n;i++){
		scanf("%s",s);
		if(q!=s[0])f=0;
		if(t[s])f=0;
		t[s]=1;
		q=s[strlen(s)-1];
	}
	if(f){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}

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

int k;
char s[100055];

int main() {
	scanf("%s", s);
	scanf("%d", &k);

	int n = strlen(s);

	for (int i = 0; i < n && k > 0; i++) {
		if (s[i] == 'a') continue;

		if (('z' - s[i]) + 1 <= k) {
			k -= ('z' - s[i]) + 1;
			s[i] = 'a';
		}
	}

	for (int i = n - 1; i >= 0 && k > 0; i--) {
		s[i] += k % 26;
		k = 0;
	}

	puts(s);

	return 0;
}

Measured memory_bytes: 384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	string s;cin>>s;SO(s);s.pub('1');
	for(int i=0;i<=6;i++){if(s[i]=='1'){cout<<6-i<<endl;RE;}}
	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;

void solve()
{
	string s,t;
	cin>>s>>t;
	int cnt=0;
	rep(i,size(s)){
		if(s[i]!=t[i])cnt++;
	}
	cout<<cnt<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

int main(){
string S,N;
cin>>S>>N;
  if(S.at(0) == N.at(2) && S.at(1) == N.at(1) && S.at(2) == N.at(0)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

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

    int flg = true;

    rep(i, s.size()) {
        if (s[i] == 'U' || s[i] == 'D') continue;
        if (i % 2 == 0) {
            if (s[i] != 'R') {
                flg = false;
                break;
            }
        } else {
            if (s[i] != 'L') {
                flg = false;
                break;
            }
        }
    }

    if (flg == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

//  || s[i] == 'U' || s[i] == 'D')


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[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 (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


long long int value(long long int x, long long int A, long long int B) {
	return floor(A * x / B) - A * floor(x / B);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	long long int A, B, N;
	cin >> A >> B >> N;

	long long int D;
	long long int temp1;
	long long int temp2;
	D = N / B;

	temp1 = D * B - 1;
	temp2 = N;

	if (value(temp1, A, B) > value(temp2, A, B)) {
		cout << value(temp1, A, B);
	}
	else {
		cout << value(temp2, A, B);
	}

	return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
   
using namespace std;
typedef long long int ll;
  
int main()
{
	int ct[26]={};
	string s;
	cin>>s;
	for(int i=0; i<s.length(); i++){
		ct[s[i]-'a']++;
	}
	bool e=0;
	for(int i=0; i<26; i++){
		if(ct[i]%2==1){
			e=1;
			break;
		}
	}
	if(e==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int >dp(n,INT_MAX),v(n,0);
  dp[0]=0;
  for(int i=0;i<n;i++)
     cin>>v[i];
  
    for(int i=0;i<n;i++)
    {
      for(int j=i+1;j<=i+2;j++)
      {
        dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
      }
    }
                  cout<<dp[n-1];
}

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

int main() {
	ll x;
	cin >> x;
	ll a = 100;
	ll ans = 0;
	while (x > a) {
		a += a * 0.01;
		ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3676
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (A >= 13) {
		cout << B << endl;
	}
	else if (6 <= A && A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


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

typedef struct TREE{
	int id;
	struct TREE *parent;
	struct TREE *child[2];
	int depth;
	int height;
}Tree;

void insert(Tree *root, Tree *z){
	Tree *y = NULL;
	Tree *x = root;
	while( x != NULL ){
		y = x;
		if( z->id < x->id ){
			x = x->child[0];
		}else{
			x = x->child[1];
		}
	}
	z->parent = y;
	if( y == NULL ){
		root = z;
	}else if( z->id < y->id ){
		y->child[0] = z;
	}else{
		y->child[1] = z;
	}
	return;
}

int find(Tree *node, int key){
	if( key < node->id ){
		if( node->child[0] == NULL ){ return 0; }
		return find(node->child[0], key);
	}else if( key > node->id ){
		if( node->child[1] == NULL ){ return 0; }
		return find(node->child[1], key);
	}
	return 1;
}

int setDepthHeight(Tree *nt, int depth){
	if( nt == NULL ){ return -1; }
	nt->depth = depth;
	int lh = setDepthHeight(nt->child[0], depth+1);
	int rh = setDepthHeight(nt->child[1], depth+1);
	nt->height = (lh>rh?lh:rh) + 1;
	return nt->height;
}

void preOrder(Tree *tr){
	if( tr == NULL ){ return; }
	printf(" %d", tr->id);
	preOrder(tr->child[0]);
	preOrder(tr->child[1]);
	return;
}

void inOrder(Tree *tr){
	if( tr == NULL ){ return; }
	inOrder(tr->child[0]);
	printf(" %d", tr->id);
	inOrder(tr->child[1]);
	return;
}

void postOrder(Tree *tr){
	if( tr == NULL ){ return; }
	postOrder(tr->child[0]);
	postOrder(tr->child[1]);
	printf(" %d", tr->id);
	return;
}

void print(Tree *root){
	inOrder(root);
	printf("\n");
	preOrder(root);
	printf("\n");
	return;
}

int main(){
	int n, id, i, j;
	char str[128];
	Tree *root = NULL, *temp = NULL;
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf("%s", str);
		if( strcmp(str, "insert") == 0 ){
			scanf("%d", &id);
			scanf("%c", &str[0]);
			temp = (Tree*)malloc(sizeof(Tree));
			temp->id = id;
			temp->parent = NULL;
			temp->child[0] = NULL;
			temp->child[1] = NULL;
			if( root == NULL ){
				root = temp;
			}else{
				insert(root, temp);
			}
		}else if( strcmp(str, "print") == 0 ){
			print(root);
		}else if( strcmp(str, "find") == 0 ){
			scanf("%d", &id);
			printf("%s\n", (find(root, id)?"yes":"no"));
		}
	}
	setDepthHeight(root, 0);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define rreps(i, n) for (int i = (n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

vector<vi32> children;
int dp[100010];

int rec(int v) {
  if (dp[v] != 0) return dp[v];
  int ret = 0;
  for (auto u: children[v]) {
    amax(ret, rec(u) + 1);
  }
  return dp[v] = ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, m;
  cin >> n >> m;
  children = vector<vi32>(n + 1);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    children[y].push_back(x);
  }
  rep(i, n + 1) rec(i);
  int ans = 0;
  rep(i, n + 1) amax(ans, dp[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10624