akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c[2][3];
    REP(i, 2)REP(j, 3) cin >> c[i][j];
    if(c[0][2] == c[1][0] and c[0][1] == c[1][1] and c[0][0] == c[1][2]){
        cout << "YES" << "\n";
    }else{
        cout << "NO" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A,B,C;
  cin>>A>>B>>C;
  if(A+B>=C){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
package main

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

func main() {
	scanInit()

	n := nextInt()
	m := nextInt()

	fmt.Println((n - 1) * (m - 1))

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int r;
    cin >> r;

    string s;

    if(r < 1200){
        s = "ABC";
    }else if(r < 2800){
        s = "ARC";
    }else{
        s = "AGC";
    }

    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
   ll n, m;
   cin >> n >> m;
   vector<ll> a(n);
   rep(i,n) cin >> a.at(i);

   //累積和
   vector<ll> sum(n+1,0);
   rep(i,n){
       sum.at(i+1) = sum.at(i) + a.at(i);
   }
   //mapを使って累積和の剰余類ごとの個数を管理
   map<ll,ll> nums;
   rep(i,n+1) nums[(sum.at(i) % m)] ++;

   //集計処理
   ll res=0;
   for(auto it:nums){
       ll num=it.second;
       res += num*(num-1)/2;
   }

    cout << res << endl;

}

Measured memory_bytes: 8512
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;

#define MOD 1000000000 + 7

bool is_prime(int n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	int p = (int)sqrt(n);
	for (int i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	int n;
	int cnt = 0;
	for (cin >> n; n--;)
	{
		int x;
		cin >> x;

		if (is_prime(x))
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int A, B, C; scanf("%d%d%d", &A, &B, &C);
  int M = max({A, B, C});

  int result;
  if ((M * 3 - (A - B - C)) % 2 == 0) {
    result = (M * 3 - (A + B + C)) / 2;
  } else {
    result = ((M + 1) * 3 - (A + B + C)) / 2;
  }

  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int H,W,N;
int sx,sy;
string S[2];
int L[2][200100];
int R[2][200100];
int U[2][200100];
int D[2][200100];
int cntL(int id,int a,int b){
	//[a,b]
	if(a==0)return L[id][b];
	return L[id][b]-L[id][a-1];
}
int cntR(int id,int a,int b){
	//[a,b]
	if(a==0)return R[id][b];
	return R[id][b]-R[id][a-1];
}
int cntU(int id,int a,int b){
	//[a,b]
	if(a==0)return U[id][b];
	return U[id][b]-U[id][a-1];
}
int cntD(int id,int a,int b){
	//[a,b]
	if(a==0)return D[id][b];
	return D[id][b]-D[id][a-1];
}
int main(){
	cin >> H >> W >> N;
	cin >> sx >> sy;
	sx--;sy--;
	cin >> S[0];
	cin >> S[1];
	for(int i=0;i<2;i++){
		for(int j=0;j<N;j++){
			if(S[i][j]=='L'){
				L[i][j]++;
			}
			if(S[i][j]=='R'){
				R[i][j]++;
			}
			if(S[i][j]=='U'){
				U[i][j]++;
			}
			if(S[i][j]=='D'){
				D[i][j]++;
			}
		}
		for(int j=1;j<N;j++){
			L[i][j]+=L[i][j-1];
			R[i][j]+=R[i][j-1];
			U[i][j]+=U[i][j-1];
			D[i][j]+=D[i][j-1];
		}
	}
	int cx,cy;
	cx = sx;
	cy = sy;
	for(int i=0;i<N;i++){
		if(S[0][i]=='R')cy++;
		if(cy>=W){
			cout << "NO" << endl;
			return 0;
		}
		if(S[1][i]=='L'&&cy>0)cy--;
	}
	cx = sx;
	cy = sy;
	for(int i=0;i<N;i++){
		if(S[0][i]=='L')cy--;
		if(cy<0){
			cout << "NO" << endl;
			return 0;
		}
		if(S[1][i]=='R'&&cy<W-1)cy++;
	}
	cx = sx;
	cy = sy;
	for(int i=0;i<N;i++){
		if(S[0][i]=='U')cx--;
		if(cx<0){
			cout << "NO" << endl;
			return 0;
		}
		if(S[1][i]=='D'&&cx<H-1)cx++;
	}
	cx = sx;
	cy = sy;
	for(int i=0;i<N;i++){
		if(S[0][i]=='D')cx++;
		if(cx>=H){
			cout << "NO" << endl;
			return 0;
		}
		if(S[1][i]=='U'&&cx>0)cx--;
	}
	cout << "YES" << endl;
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){

    std::string ans;
    if( S[0] == S[1] && S[1] == S[2] && S[2] == S[0] ){
        ans = NO;
    }else{
        ans = YES;
    }

    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)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






string S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    int n = S.length();
    
    int ans = 0;

    {
        int d = S[0] - '0' - 1;
        d += 9 * (n - 1);
        chmax(ans, d);
    }

    {
        int d = 0;
        fore(c, S) d += c - '0';
        chmax(ans, d);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		double numR = 0.0;

		//?§£????????°
		double circle = 0.0;
		double area = 0.0;
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String Input = br.readLine();

			numR = Double.parseDouble(Input);
			area = Math.PI * (numR * numR);
			circle = Math.PI * (2 * numR);
			System.out.println(String.format("%.6f", area) + " " + String.format("%.6f", circle));

		}catch (NumberFormatException e) {
			System.out.println(e);
		} catch (IOException e) {
			System.out.println(e);
		}
	}

}

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

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

    vector<int> A(N), W(N);

    for(int i=0; i<M; i++) {
        int a;
        string s;
        cin >> a >> s;

        if(s == "WA" && A[a-1] != 1) {
            W[a-1]++;
        }
        else if(s == "AC") {
            A[a-1] = 1;
        }
    }
    int a_sum = 0, w_sum = 0;
    for(int i=0; i<N; i++) {
        a_sum += A[i];
        if(A[i] == 1) {
            w_sum += W[i];
        }
    }
    cout << a_sum << " " << w_sum << endl;
}



Measured memory_bytes: 4008
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define re(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second


ll binpow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return binpow(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0,k,x,r,l,t;
    string s;
    cin >> s;
    ll sum=0;
    n=s.size();
    rep(i,n) 
    {
          sum+=s[i]-'0';
    }
    
    if(sum%9==0) cout << "Yes" ;
    else cout << "No" ;
    
    return 0;
}

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

int main() {

  ll n, k;
  cin >> n >> k;
  vector<ll> route(n);
  rep(i, n) {
    ll a;
    cin >> a;
    route[i] = a -1;
  }

  unordered_map<ll,ll> arrive;
  rep(i,n) arrive[i] = -1;
  ll now = 0;
  arrive[now] = 0;
  rep(i, k) {
    now = route[now];
    if(arrive[now] != -1) {
      ll loop = i + 1 - arrive[now];
      k = (k - arrive[now]) % loop;
      rep(i, k) {
        now = route[now];
      }
      break;
    }
    arrive[now] = i + 1;
  }
  

  cout << now+1 << endl;
  return 0;
}

Measured memory_bytes: 13036
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  vector<ll>  ans;
  int count = 0;
  rep(i, n - 1){
    if(a[i] == a[i + 1]){
      ans.push_back(a[i]);
      count++;
      i++;
    }
  }
  if(count >= 2)  cout << ans[0] * ans[1] << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int N;
vector<int> graph[100005];
vector<int> dist;

void dfs(int cur, int d=0, int p=-1) {
  dist[cur] = d;
  for (int next : graph[cur]) {
    if (next == p) continue;
    dfs(next, d+1, cur);
  }
}

vector<int> calcDist(int start) {
  dist = vector<int> (N+1);
  dfs(start);
  return dist;
}

int main() {
  // UとVからそれぞれの頂点までの距離を求める、Uからの距離が小さいものの中でVからの距離-1が最大のもの
  int U, V;
  cin >> N >> U >> V; // 鬼の青木くんがVに最初いる
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  vector<int> distU = calcDist(U);
  vector<int> distV = calcDist(V);
  
  int ans = 0;  
  for (int i = 1; i < N+1; i++) {
    if (distU[i] < distV[i]) {
      ans = max(ans, distV[i] - 1);
    }
  }
  cout << ans << '\n';
  return 0;
}

// 37

Measured memory_bytes: 13588
N = int(input())
A = [0]*N
B = [[0]*19 for x in range(19)]
C = [0]*N
D = [0]*N
a,b,c,d,e,ans = 0,['0']*9,0,0,0,0
for i in range(N):
    c = (input()+'.0').split('.')
    b = ['0']*9
    for k,v in enumerate(c[1]):
        b[k] = v
    A[i] = int(c[0]+''.join(b))

# print(*A)

for i in range(N):
    d,e = 0,0
    while (A[i] % 2 == 0) and (d < 18):
        A[i] //= 2
        d += 1
    while (A[i] % 5 == 0) and (e < 18):
        A[i] //= 5
        e += 1
    C[i] = d
    D[i] = e
    B[d][e] += 1

for i in range(N):
    c = C[i]
    d = D[i]
    B[c][d] -= 1
    for j in range(18-c,19):
        for k in range(18-d,19):
            ans += B[j][k]

print(ans)

Measured memory_bytes: 74800
#include <algorithm>
#include <cstring>
#include <cstdio>
int arr[1000005];
char str[500005];
inline bool chk(int x)
{
	int len = 0, sum = 0;
	for (int i = 0; str[i]; i++)
		arr[len++] = (str[i] - '0') * 9;
	arr[0] += 9 * x;
	for (int i = 0; i < len; i++)
	{
		if (arr[i] <= 9)
			continue;
		if (i + 1 == len)
			arr[len++] = 0;
		arr[i + 1] += arr[i] / 10;
		arr[i] %= 10;
	}
	for (int i = 0; i < len; i++)
		sum += arr[i];
	return sum <= 9 * x;
}
int main()
{
	// freopen("AGC011-E.in", "r", stdin);
	scanf("%s", str);
	int n = strlen(str), l = 1, r = n, ans;
	std::reverse(str, str + n);
	while (l <= r)
	{
		int m = l + r >> 1;
		if (chk(m))
		{
			ans = m;
			r = m - 1;
		}
		else
			l = m + 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

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

        int n = scanner.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        }

        int[] dp = createArray(n, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            dp[i] = dp[i -1] + Math.abs(h[i] - h[i - 1]);
            if (i > 1) {
                dp[i] = Math.min(dp[i], dp[i -2] + Math.abs(h[i] - h[i -2]));
            }
        }

        System.out.println(dp[n - 1]);
    }

    private static int[] createArray(int size, int defaultValue) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = defaultValue;
        }
        return array;
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N,X; cin >> N >> X;
    int sum = 0;
    int ans = 1;
    REP(i,N){
        int L; cin >> L;
        sum += L;
        if(sum <= X) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
n = int(input())
chk = [[set(),set()] for _ in range(n)]
for o in range(n):
  a = int(input())
  for i in range(a):
    x,y = [int(i) for i in input().split()]
    if y == 0:
      chk[o][0].add(x-1)
    if y == 1:
      chk[o][1].add(x-1)
    
chk = tuple(chk)
answer = 0
for i in range(2**n):
  b = format(i,'b')
  b = b.zfill(n)[::-1]
  chk_0 = set()
  chk_1 = set()
  p = []
  for j in range(n):
    if b[j] == '1':
      p.append(j)
      chk_1.add(j)
    if b[j] == '0':
      chk_0.add(j)
  for i in p:
    if not chk[i][0] <= chk_0:
      break
    if not chk[i][1] <= chk_1:
      break
    if i == p[len(p)-1]:
      answer = max(answer,len(p))
      
print(answer)

Measured memory_bytes: 53340
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int p = scanner.nextInt();
        int q = scanner.nextInt();
        int r = scanner.nextInt();

        int a = p+q;
        int b = p+r;
        int c = r+q;
        
        int min1 = Math.min(a, b);
        min1 = Math.min(c, min1);
        System.out.println(min1);
    }
}

Measured memory_bytes: 23892
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a,b,ab,x,y,rs,q;
    scanf("%d %d %d %d %d",&a,&b,&ab,&x,&y);
    if(ab*2>=a+b){
        rs=a*x+b*y;
    }
    else{
        q=min(x,y);
        rs=ab*2*q;
        x-=q;
        y-=q;
        if(ab*2*max(x,y)>=a*x+b*y){
            rs+=a*x+b*y;
        }
        else{
            rs+=ab*2*max(x,y);
        }
    }
    printf("%d\n",rs);
    return 0;
}


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

const int K_MAX = 100010;
bool dp[K_MAX];

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  for(int i=0; i<N; i++){
    dp[vec[i]] = true;
  }
  
  for(int i=0; i<=K; i++){
    for(int j=0; j<N; j++){
      if(i - vec[j] >= 0){
        if(!dp[i - vec[j]]){
          dp[i] = true;
        }
      }
    }
  }
  
  if(dp[K]){
    cout << "First" << endl;
  }
  else{
    cout << "Second" << endl;
  }
}

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

long long ba, p;
string s;

int main() {
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'W') p += ba;
        else ++ba;
    }
    cout << p << endl;
}

Measured memory_bytes: 640
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <complex>
#include <iomanip>
#include <bitset>
#include <random>
#include <vector>
#include<string>

using namespace std;

int main() {
	int h, w, n, sr, sc, l,r,u,d,i;
	char s[222222], t[222222];
	cin >> h >> w >> n >> sr >> sc >> s >> t;
	l = 1;
	r = w;
	u = 1;
	d = h;
	for (i = n - 1; i >= 0; i--) {
		if (t[i] == 'L'&&r>0&&r<w)
			r++;
		if (t[i] == 'R'&&l <=w&&l>1)
			l--;
		if (t[i] == 'U'&&d >0&&d<h)
			d++;
		if (t[i] == 'D'&&u <=h&&u>1)
			u--;
		if (s[i] == 'L')
			l++;
		if (s[i] == 'R')
			r--;
		if (s[i] == 'U')
			u++;
		if (s[i] == 'D')
			d--;
	}
	if (u <= sr && sr <= d && l <= sc && sc <= r)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


Measured memory_bytes: 640
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007
#include <iostream>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	int debt = 100000;
	for (int i = 0; i < n;i++) {
		debt *= 1.05;
		if (debt % 1000 != 0) {
			debt = (debt / 1000) * 1000  + 1000;
		}
	}
	cout << debt << endl;
}

Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int n;
    n = s.length();
    ll k;
    cin >> k;
    char sp = s[0];
    int count = 1;
    vector<int> l;
    for(int i=1; i<n; i++){
        if(sp==s[i]){
            count += 1;
        }else{
            l.push_back(count);
            count = 1;
        }
        sp = s[i];
    }
    l.push_back(count);
    int ln = l.size();
    if(s[0] == s[n-1]){
        if(ln == 1){
            cout << l[0] * k / 2 << endl;
        }else{
            ll ans = 0;
            for(int i=1; i<ln-1; i++){
                ans += l[i]/2;
            }
            ans = ans * k;
            ans += l[0]/2 + l[ln-1]/2;
            ans += ((l[0]+l[ln-1])/2)*(k-1);
            cout << ans << endl;
        }
    }else{
        ll ans = 0;
        for(int i=0; i<ln; i++){
            ans += l[i]/2;
        }
        cout << ans*k << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = a; i <b; i++)
#define forn(i,a,b) for (int i = a; i >b; i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


ll fact(ll n)
{
  if(n==0 || n==1)
  return 1;
  else
  return (n*fact(n-1)%mod)%mod;
}

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

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

ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

int check_palin(string s)
{
  string str=s;
  reverse(str.begin(),str.end());
  if(str==s)
  return 1;
  else 
  return 0;
}

vector<ll> divisors(ll n)
{
  vector<ll> v;
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(i==n/i)
      v.PB(i);
      else
      v.PB(i),v.PB(n/i);
    }
  }
return v;
}

ll bin_expo(int x,int n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_expo(x*x,n/2);
    else                             //n is odd
        return x*bin_expo(x*x,(n-1)/2);
}

ll modular_expo(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modular_expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modular_expo((x*x)%M,(n-1)/2,M))%M;
}

// <----- Actual solve() function to print output -----> //
void solve()
{
  ll n,ans=0,z=0;
  cin>>n;
  int a[n];
  map<int,int> mp;
  ll pre[n]={0},suf[n]={0};
  forp(i,0,n)
  {
    cin>>a[i];
    if(i>0)
    pre[i]=pre[i-1]^a[i];
    else
    pre[i]=a[i];
  }

  forn(i,n-1,-1)
  {
    if(i+1<n)
    suf[i]=suf[i+1]^a[i];
    else
    suf[i]=a[i];
  }

  forp(i,0,n)
  {
    if(i==0)
    cout<<suf[i+1]<<" ";
    else if(i==n-1)
    cout<<pre[i-1]<<" ";
    else
    cout<<(pre[i-1]^suf[i+1])<<" ";
  } 
  //cout<<"\n";      //if t>1 uncomment this
}

// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
    single_testcase_t   //Uncomment this if only single testcase & single answer to print
   // multiple_testcases_t  //Uncomment this if t>1(t is given in question)(multiple testcases)      
return 0;
}
            
            
            
            

Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,ans = 0;
  cin >> A >> B;
  
  for (int i = A;i <= B;++i){
    if (((i/10000)==(i%10))&&(((i/1000)%10)==((i%100)/10))){
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n;
    vector<int> V(n), W(n);
    for(int i = 0; i < n; i++) {
        cin >> V[i] >> W[i];
    }
    int M = 1 << 11;
    vector<P> rec1[M];
    rec1[0].emplace_back(0, 0);
    rec1[0].emplace_back(W[0], V[0]);
    for(int i = 1; i < M; i++) {
        if(i >= n) {
            break;
        }
        vector<P> tmp;
        for(auto j : rec1[(i - 1) / 2]) {
            tmp.emplace_back(j.first, j.second);
            tmp.emplace_back(j.first + W[i], j.second + V[i]);
        }
        sort(ALL(tmp));
        int now = -1;
        for(auto j : tmp) {
            if(now < j.second) {
                rec1[i].emplace_back(j);
                now = j.second;
            }
        }
    }
    cin >> q;
    while(q--) {
        int v, L;
        cin >> v >> L;
        v--;
        vector<P> item;
        while(v >= M) {
            item.emplace_back(W[v], V[v]);
            v = (v - 1) / 2;
        }
        vector<P> rec2;
        int N = item.size();
        for(int bit = 0; bit < (1 << N); bit++) {
            int sumw = 0, sumv = 0;
            for(int i = 0; i < N; i++) {
                if(bit & (1 << i)) {
                    sumw += item[i].first;
                    sumv += item[i].second;
                }
            }
            rec2.emplace_back(sumw, sumv);
        }
        int ans = 0;
        for(auto j : rec2) {
            P p = P(L - j.first, INF);
            auto it = lower_bound(ALL(rec1[v]), p);
            if(it != rec1[v].begin()) {
                it--;
                chmax(ans, it->second + j.second);
            }
        }
        print(ans);
    }
}


Measured memory_bytes: 27416
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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



int main(){
    int N;
    cin>>N;
    while(N>1000){
        N-=1000;
    }
    out(1000-N);
    
}

Measured memory_bytes: 3616
K = int(input())
S = input()

MAX = 2 * 10 ** 6 + 10
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1

# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1

# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1

for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD


ans = 0
n = len(S)
for k in range(K + 1):
    tmp = (pow(25, K - k, MOD) * pow(26, k, MOD)) % MOD
    ans += comb(n + K - k - 1, n - 1) * tmp % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 132956
#include <bits/stdc++.h>
using namespace std;
#define lli long long
vector<pair<lli,lli> > v;

bool cmp(pair<lli,lli> a, pair<lli,lli> b)
{
    if(a.second<b.second) return true;
    if(a.second>b.second) return false;
    
    return a.first>b.first;
}

int main() 
{
    int n;
    cin >> n;
    lli x,y;
    
    for(int i=0;i<n;i++){
        cin >> x >> y;
        v.push_back(make_pair(x,y));
    }
    
    sort(v.begin(),v.end(),cmp);
    
    lli sum = 0;
    
    for(int i=0;i<n;i++){
        sum+=v[i].first;
        if(sum>v[i].second){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
template <class T>
map< T, int > prime_factor(T n) {
    map< T, int > ret;
    for(T i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

void Main(){
  ll n;
  cin>>n;
  string s,ans,res;
  cin>>ans;
  sort(rng(ans));
  rep(i,n-1){
    cin>>s;
    sort(rng(s));
    string ret;
    set_intersection(rng(s),rng(ans),inserter(ret,ret.end()));
    // cout<<ret<<endl;
    ans = ret;
  }
  cout<<ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<int> memory;

string addZero(string num, int cnt) {
    string str = num;
    int size = num.size();

    for (int i = 0; i < cnt - size; ++i) {
        str = '0' + str;   
    }    
    return str;
}

string createMaxNumber(string num) {
    sort(begin(num), end(num), greater<char>());
    return num;
}

string createMinNumber(string num) {
    sort(begin(num), end(num));
    return num;
}

int equalNumber(int num) {
    int ans = 0;
    for(auto e : memory) {
        if (e == num) {
            return ans;
        }
        ans++;
    }
    return -1;
}

int main(int argc, char const *argv[]) {
    string a;
    int L;

    while(cin>>a>>L, a != "0" || L) {
        memory.clear();
        int j = 0;
        a = addZero(a, L);
        memory.push_back(stoi(a));

        while(1) {
            j++;
            int max = stoi(createMaxNumber(a));
            int min = stoi(createMinNumber(a));
            int diff = max - min;
            int i = equalNumber(diff);

            if (i >= 0) {
                cout<<i<<" "<<diff<<" "<<j-i<<endl;
                break;
            }

            memory.push_back(diff);
            a = to_string(diff);
            a = addZero(a, L);
        }
    }
    return 0;
}

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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let abx = read_vec::<i64>();
    let ans = if abx[0] == 0 {
        1 + abx[1] / abx[2]
    } else {
        (abx[1] / abx[2]) - ((abx[0] -1)/ abx[2])
    };
    println!("{}",ans );
    }

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

long long k , mod , inf=3234566667;
vector<long long> vec;

void dfs(long long x){
    if(x <= inf){
        vec.push_back(x);
        mod = x%10;
        if(mod > 0){
            dfs(x*10+mod-1);
        }
        
        mod = x%10;
        if(mod < 9){
            dfs(x*10+mod+1);
        }
        
        mod  = x%10;
        dfs(x*10+mod);
    }
}

int main(){
    cin>>k;
    for(long long i=1;i<10;i++){
        dfs(i);
    }
    
    sort(vec.begin(),vec.end());
    
    cout<<vec[k-1]<<endl;
    return(0);
}


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

typedef long long LL;  //Attention!!
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

LL powa(LL a,LL b)
{
if(b==0) return 1;
if(b%2==1) return (powa(a,b-1)*a)%M;

LL c = powa(a,b/2);

return (c*c)%M;
}

LL inv(LL a)
{
return powa(a,M-2);
}

const int N = 1e5 + 5;

LL ans[N];
LL ans2[N];

LL build(LL a,LL b)
{
ans[1] = 1;
int i;
for(i=2;i<=b;i++)
	{
	ans[i] = (ans[i-1]*(a+i-2))%M;
	ans[i] = (ans[i]*inv(i-1))%M;
	}
}

LL build2(LL a,LL b)
{
//cout<<inv(3)<<' '<<(3*inv(3))%M<<endl;

ans2[1] = 1;
int i;
for(i=2;i<=b;i++)
	{
	ans2[i] = (ans2[i-1]*(a+i-2))%M;
	ans2[i] = (ans2[i]*inv(i-1))%M;
	}
}

int main()
{
ios_base::sync_with_stdio(0); cout.precision(15);cout.setf(ios::fixed);
LL h,w,a,b,i;

cin>>h>>w>>a>>b;

build(b,h-a);
build2(w-b,h);

LL cnt = 0;

 

for(i=1;i<=(h-a);i++)
	cnt = (cnt + ans[i]*ans2[h-i+1])%M;

cout<<cnt<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

int main() {
    FASTIO;
    LL a, b;
    while (cin >> a >> b) cout << a * b / __gcd(a, b) << '\n';
    return 0;
}


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

int main() {
    long double a, b, x=0;
    cin >> a >> b >> x;

    long double answer = 0L;
    long double tmp = 0L;
 
    if(x <= a * a * b /2){
        tmp = 2 * x / a / b;
        answer = 90 - (360 * atan(tmp / b) / 2 / 3.14159265358979323846L);
    }
    else{
        tmp = 2 * (b - x / a / a);
        answer = 90 - (180 / 3.14159265358979323846L * atan(a / tmp));
    }

    cout << fixed << setprecision(10) << answer << endl;

}


Measured memory_bytes: 256
def main():
    from queue import deque

    K = int(input())
    q = deque()
    for i in range(1, 10):
        q.append(i)
    for i in range(K - 1):
        s = q.popleft()
        for j in range(-1, 2):
            add = (s % 10) + j
            if add >= 0 and add <= 9:
                q.append(s * 10 + add)
    print(q.popleft())


main()


Measured memory_bytes: 19760
# coding: utf-8
# Your code here!
def main():
    X, N = map(int, input().split())
    if N == 0:
        print(X)
        return 0
    p_list = list(map(int, input().split()))
    
    
    ans = X
    i = 0
    while True:
        tmp_n = X - i
        if tmp_n not in p_list:
            ans = tmp_n
            break
        tmp_p = X + i
        if tmp_p not in p_list:
            ans = tmp_p
            break
        i += 1        
    
    print(ans)

main()

Measured memory_bytes: 9140
import java.util.*;

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

    int n = sc.nextInt();
    int k = sc.nextInt();
    long ans = 0;
    if (k <= 2 * n) {
      if (k % 2 == 1) {
        ans = (long)Math.pow(n/k, 3);
      } else {
        ans += (long)Math.pow(n/k, 3);
        ans += (long)Math.pow((n-k/2)/k+1, 3);
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

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

        int seconds = value % 60;
        int minutes = (value / 60) % 60;
        int hours = value / 3600;

        System.out.println(hours + ":" + minutes + ":" + seconds);
        scanner.close();
    }
}



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

int main(){
	int n;
	stack<int> st;
	while(cin >> n){
		if(n == 0){
			cout << st.top() << endl;
			st.pop();
		}else{
			st.push(n);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#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<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
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
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int n,i;cin>>n;
	vector<llint>b(n);
	for(i=0;i<n;i++){int a;cin>>a;b[a-1]++;}
	SO(b);REV(b);
	vector<llint>c(n+1);
	for(i=0;i<n;i++){c[b[i]]++;}
	for(i=n;i>0;i--){c[i-1]+=c[i];}//回転
	vector<llint>kai(n+1);
	llint gen=0;
	for(i=1;i<=n;i++){//i回 可能な最大のKを求めたい
		gen+=c[i];
		kai[i]=gen/i;
	}
	vector<llint>ans(n+1);
	for(i=1;i<=n;i++){ans[kai[i]]=i;}
	for(i=n;i>0;i--){maxeq(ans[i-1],ans[i]);}
	for(i=1;i<=n;i++){cout<<ans[i]<<endl;}
	return 0;
}


Measured memory_bytes: 10240
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int n;
int s[110];

int main(){
    while(scanf("%d",&n)==1)
    {
         for(int i=1;i<=n;i++)
            scanf("%d",&s[i]);
         sort(1+s,1+s+n);
         int sum,ans;
         sum=ans=0;
         for(int i=1;i<=n;i++)
         {
            sum+=s[i];
            ans+=sum;
            }
         printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 0
/* https://atcoder.jp/contests/abc123/tasks/abc123_a */

#include <iostream>
#include <vector>
#include <cmath>

std::vector<int> x(5);
int k;

void solve()
{
  for (int i = 0; i < 5; ++i) {
    for (int j = i+1; j < 5; ++j) {
      int dist = std::abs(x.at(i)-x.at(j));
      if (dist > k) {
        std::cout << ":(" << std::endl;
        return;
      }
    }
  }
  std::cout << "Yay!" << std::endl;
  return;
}

int main(int argc, char *argv[])
{
  // Input
  for (int& e: x)
    std::cin >> e;

  std::cin >> k;

  // Output
  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    
    String[] S = sc.nextLine().split(" ");
    List<Integer> list = new ArrayList<>();
    for(int i = 0; i < N; i++){
      list.add(Integer.parseInt(S[i]));
    }
    
    Deque<Integer> deq = new ArrayDeque<>();
    while(list.size() > 0){
      int n = list.size();
      for(int i = n-1; i >= 0; i--){
        if(list.get(i) == i+1){
          list.remove(i);
          deq.push(i+1);
          break;
        }
      }
      if(list.size() == n){
        System.out.println(-1);
        return;
      }
    }
    
    while(deq.size() > 0){
      System.out.println(deq.pop());
    }
  }
}

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

#define si(n) scanf("%d",&n)
#define MAX 103

int a[MAX],b[MAX],n;

int main()
{
    int i,j;
    si(n);
    for(i=1;i<=n;i++){
        si(a[i]);
        a[i]+=a[i-1];
    }
    for(i=1;i<=n;i++){
        si(b[i]);
    }
    for(i=n-1;i>=1;i--)b[i]+=b[i+1];
    int ans=0;
    for(i=1;i<=n;i++){
        ans=max(ans,a[i]+b[i]);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, m, cnt, num;
arr fir, from;
struct
{
	int to, last;
} e[Maxn << 2];
void con(int u, int v)
{
	e[++cnt].to = v;
	e[cnt].last = fir[u];
	fir[u] = cnt;
}
void BFS(int x)
{
	queue<int> q;
	q.push(x);
	while (!q.empty())
	{
		x = q.front();
		q.pop();
		for (int next = fir[x], nx; next; next = e[next].last)
		{
			nx = e[next].to;
			if (nx != 1 && !from[nx])
			{
				num--;
				from[nx] = x;
				q.push(nx);
			}
		}
	}
}
int main()
{
	rg int a, b;
	cin >> n >> m;
	num = n - 1;
	for (rg int i = 1; i <= m; i++)
	{
		a = read();
		b = read();
		con(a, b);
		con(b, a);
	}
	BFS(1);
	if (!num)
	{
		puts("Yes");
		for (rg int i = 2; i <= n; i++)
			printf("%d\n", from[i]);
	}
	else
		puts("No");
	return 0;
}
//D

Measured memory_bytes: 7580
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    x,y = IL()
    if x==y:
        print(-1)
        exit()
    for rep in range(x,10**9+1,x):
        if rep%y!=0:
            print(rep)
            exit()
    print(-1)
    exit()

Measured memory_bytes: 8992
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>

template<class T>
T input()
{
	T val, val1;
	std::cin >> val >> val1;
	if (val == '\0')return EOF;
	else			return val+val1;
}

int main()
{
	std::vector<int> x;
	int a, b;
	while (scanf("%d %d", &a, &b) != EOF)
		x.push_back(a+b);

	for (int i = 0; i < x.size(); ++i)
		std::cout << static_cast<int>(log10(x[i])) + 1 << std::endl;
	return 0;
}

Measured memory_bytes: 1264
#!/usr/bin/env python
import math


def main():
    a, b, c = sorted([int(a) for a in input().split()])

    add = 0
    if a % 2 == 0:
        if b % 2 == 0:
            if c % 2 == 0:
                pass
            else:
                add = 1
                b += 1
                a += 1
        else:
            if c % 2 == 0:
                add = 1
                a += 1
                c += 1
            else:
                add = 1
                b += 1
                c += 1
    else:
        if b % 2 == 0:
            if c % 2 == 0:
                add = 1
                b += 1
                c += 1
            else:
                add = 1
                a += 1
                c += 1
        else:
            if c % 2 == 0:
                add = 1
                a += 1
                b += 1
            else:
                pass

    print(add+(c - b + c - a) // 2)


if __name__ == '__main__':
    main()


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

int main() {
  int N,Z;
  cin>>N;
  vector<tuple<int,int,int>> p(N);
  for(int i=0;i<N;i++){
    int a,b,c;
    cin>>a>>b>>c;
    p.at(i)=make_tuple(c,a,b);
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      int h,a,b;
      Z=0;
      tie(h,a,b)=p.at(0);
      int H=h+abs(a-i)+abs(b-j);
      for(int k=1;k<N;k++){
        tie(h,a,b)=p.at(k);
        if(h!=max(H-abs(a-i)-abs(b-j),0)){
          Z++;
          break;
        }
      }
      if(Z==0){
        cout<<i<<" "<<j<<" "<<H<<endl;
        Z=-1;
      }
    }
    if(Z==-1){
      break;
    }
  }
      
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")
  

int m;
int n;

void solve() {
  int s = n + m;
  int f = s * (s-1);
  int r = f/2 - n*m;
  cout << r;
}

void input() {
  cin >> n >> m;
}
 
int main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256