akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
if sum(A) <= K:
    print(0)
    exit()

def ok(c):
    s = 0
    for i in range(N):
        s += max(0, A[i] - c // F[i])
    return s <= K

A.sort()
F.sort(reverse=True)
l, r = -1, 10 ** 12
while l + 1 < r:
    c = (l + r) // 2
    if ok(c):
        r = c
    else:
        l = c
print(r)


Measured memory_bytes: 119500
import java.util.Scanner;

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

        char[] S = sc.next().toCharArray();

        sc.close();

        boolean YYMM = true;
        boolean MMYY = true;

        if(S[0] == '0'){
            if(S[1] == '0'){
                MMYY = false;
            }
        }else if(S[0] == '1'){
            if(S[1] != '0' && S[1] != '1' && S[1] != '2'){
                MMYY = false;
            }
        }else{
            MMYY = false;
        }

        if(S[2] == '0'){
            if(S[3] == '0'){
                YYMM = false;
            }
        }else if(S[2] == '1'){
            if(S[3] != '0' && S[3] != '1' && S[3] != '2'){
                YYMM = false;
            }
        }else{
            YYMM = false;
        }

        String result = null;

        if(YYMM && MMYY){
            result = "AMBIGUOUS";
        }else if(YYMM && !MMYY){
            result = "YYMM";
        }else if(!YYMM && MMYY){
            result = "MMYY";
        }else{
            result = "NA";
        }

        System.out.println(result);

    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int k,n;
  cin>>k>>n;
  vector<ll> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  ll sum=0;
  for(int i=1;i<n;i++)
  {
    sum+=(v[i]-v[i-1]);
  }
  ll ans=sum;
  for(int i=1;i<n;i++)
  {
    ans=min(ans,sum+(k-v[n-1])+(v[0])-(v[i]-v[i-1]));
  }
  cout<<ans;
  return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;
	long cnt{0};
	map<char, vector<int>> mp;
	for(int i = 0; i < n; ++i) {
		mp[s[i]].push_back(i);
	}

	int temp{0};
	for(auto x: mp['R']) {

		for(auto y: mp['G']) {


			if(x > y) {

				if(binary_search(mp['B'].begin(), mp['B'].end(), x + (x-y))) ++temp;// y x z
				if(binary_search(mp['B'].begin(), mp['B'].end(), y - (x-y))) ++temp;//z y x
				if((x-y)%2==0 && binary_search(mp['B'].begin(), mp['B'].end(), (x + y)/2)) ++temp;// y z x
			} else {

				if(binary_search(mp['B'].begin(), mp['B'].end(), y + (y-x))) ++temp;// x y z
				if(binary_search(mp['B'].begin(), mp['B'].end(), x - (y-x))) ++temp;//z x y
				if((y-x)%2==0 && binary_search(mp['B'].begin(), mp['B'].end(), (y + x)/2)) ++temp;// x z y
			}

		}
	}
	cnt = mp['R'].size() * mp['G'].size() * mp['B'].size();
	cout << cnt - temp;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
string eki = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
	int N;
	while(1){
        cin>>N; 
        if(N==0) break;
		vector<int> k(N);
		for(int i=0; i<N; i++)cin >> k[i];
		
		string S;
		cin >> S;
		
		string ans;
		int pos=0;
		for( int i=0; i<S.size(); i++){
			int num;
			if('a'<= S[i] && S[i] <= 'z'){
				num = S[i] - 'a';
			}
			else if('A' <= S[i] && S[i] <= 'Z'){
				num = S[i] - 39;
			}
			char res = eki[ ( num - k[pos] + 52 ) % 52 ];
			pos = (pos+1)%N;
			ans += res;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
     
    using namespace std;
     
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double dd;
    typedef vector<int> vi;
    typedef vector<ll> vll;
    typedef pair<int, int> ii;
    typedef pair<ll, int> li;
    typedef pair<int, ll> il;
    typedef pair<ll , ll> lli;
    typedef vector<ii> vii;
    typedef vector<il> vil;
    typedef vector<li> vli;
    typedef vector<lli> vlli;
     
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    #define in insert
    #define f0(b) for(int i=0;i<(b);i++)
    #define f00(b) for(int j=0;j<(b);j++)
    #define f1(b) for(int i=1;i<=(b);i++)
    #define f11(b) for(int j=1;j<=(b);j++)
    #define f2(a,b) for(int i=(a);i<=(b);i++)
    #define f22(a,b) for(int j=(a);j<=(b);j++)
    #define sf(a) scanf("%lld",&a)
    #define sff(a,b) scanf("%lld %lld", &a , &b)
    #define pf(a) printf("%lld\n",a)
    #define pff(a,b) printf("%lld %lld\n", a , b)
    #define PI 3.14159265359
    #define bug printf("**!\n")
    #define mem(a , b) memset(a, b ,sizeof(a))
    #define front_zero(n) __builtin_clzll(n)
    #define back_zero(n) __builtin_ctzll(n)
    #define total_one(n) __builtin_popcountll(n)
     
    const ll mod = (ll)1e9+7;
    const ll maxn = (ll)3e5+5;
    const int nnn = 1048590;
    const int inf = numeric_limits<int>::max()-1;
    //const ll INF = numeric_limits<ll>::max()-1;
    const ll INF = 1e18;
     
    ll dx[]={0,1,0,-1};
    ll dy[]={1,0,-1,0};
    ll dxx[]={0,1,0,-1,1,1,-1,-1};
    ll dyy[]={1,0,-1,0,1,-1,1,-1};
     
    ll dp[100005][72];
    ll n;
    ll ans = inf;
    void DP(ll d , ll one){
     
    	if(one > 70) return;
    	if(d == 0){
    		ans = min(ans , one);
    		return;
    	}
    	ll &ret = dp[d][one];
    	if(ret != -1) return;
    	ret = inf;
    	DP( (d*10)%n , one);
        DP((d*10 + 1)%n , one+1);
    	return;
    }
     
    void solve(){
    	cin >> n;
    	mem(dp , -1);
    	DP(1 , 1);
    	cout << ans << '\n';
    	return;
    }
     
     
    int main() {
        ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
		solve(); 
        return 0;
    }

Measured memory_bytes: 220384
import java.util.Scanner;



public class Main{

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n;
		n = stdin.nextInt();
		for(int i=0;i<n;i++){
			int Y,M,D,X,a,b,c,d;
			Y = stdin.nextInt();
			M = stdin.nextInt();
			D = stdin.nextInt();
			a=(Y-1)/3;
			b=Y-1-a;
			X=a*200+b*195;
			if(Y%3==0){
				X=X+(M-1)*20;
			}else{
				c=(M-1)/2;
				d=(M-1)-c;
				X=X+c*19+d*20;
			}
			X=X+D;
			System.out.println(196471-X);
		}
	}

}

Measured memory_bytes: 26668
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define M 1000000007  // 10^9+7

ld coins(ld arr[], int n, int heads, int i, vector<vector<ld>> &dp){
    if(i == n)
        return heads > n/2;
    if(dp[i][heads] != -1)
        return dp[i][heads];
    ld op1 = coins(arr, n, heads+1, i+1, dp)*arr[i];
    ld op2 = coins(arr, n, heads, i+1, dp)*(1-arr[i]);
    ld ans = op1 + op2;
    dp[i][heads] = ans;
    return ans;
}

int main()
{
 int n;
 cin>>n;
 ld arr[n];
 for(int i=0; i<n; i++)
    cin>>arr[i];
 vector<vector<ld>> dp(n, vector<ld>(n+1, -1));
 ld ans = coins(arr, n, 0, 0, dp);
 cout<<fixed<<setprecision(9)<<ans;
 return 0;
}



Measured memory_bytes: 144172
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
const int N = 2e5+5;


vector<ll>ans,veca,vecb;
vector<int>adj[N];
vector<double>aka;
vector<pair<int,double>>dp[N];
vector<bool>vis;


void init(int n){
    ans.clear();veca.clear();aka.clear();vis.clear();
    vecb.clear(),vecb.resize(n);veca.resize(n);vis.resize(n);
    for (int i = 0; i <n; i++) {
        vis[i]=0;
    }
    for (int i = 0; i<=n; i++) {
        adj[i].clear();
    }
    for (int i = 0; i <=n; i++) {
        dp[i].clear();
    }
    
}
int power(int a,int n){
    int res=1;
    for (int i = 0; i < n; i++) {
        res=(1LL*res*a)%mod;
    }
    return res%mod;
}
int add(int a){
    if(a<0) a+=mod;
    return a;
}
void solve(){
    int n,x,t;
    cin>>n>>x>>t;
    int myans=n/x;
    if(n%x) myans++;
    cout<<myans*t;
    
}

int main(){
   
   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
        
        
    return 0;
}

Measured memory_bytes: 12980
#include<iostream>
using namespace std;
int main(){
  int S,K;
  cin>>K>>S;
  int count=0;
  for(int i=0;i<=K;i++){
    for(int k=0;k<=K;k++){
      int z=S-i-k;
      if(0<=z && z<=K){
        count++;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {

	int n, k;
	cin >> n >> k;

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

	sort(h.begin(), h.end());
	vector<int>aida(n - 1);

	for (int i = 0; i < n - 1; i++)
		aida[i] = h[i + 1] - h[i];

	int ans = 2000000000;

	for (int i = 0; i <= n - k; i++) {
		int sum = 0;
		for (int j = 0; j < k - 1; j++) {
			sum += aida[i + j];
		}

		ans = min(ans, sum);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, B, C, K) = nextLongList()
    val ans = when {
        K <= A -> K
        K <= A + B -> A
        else -> A - (K - A - B)
    }
    println(ans)
}


Measured memory_bytes: 36544
#n,a,b = [int(i) for i in input().split()]


n=int(input())
a=[0]*n
b=[0]*n
d=[0]*n
#print(d[2])
for i in range(n):
    aa,bb=[int(i) for i in input().split()]
    a[i] = aa
    d[i] = aa+bb

d.sort(reverse = True)
#print(d)
#print(d[1::2])
print(sum(a) - sum(d[1::2]))





Measured memory_bytes: 12188
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

typedef pair <long long, long long>  pii;

const int MAXN = 500 + 5, MAXC = 30 + 3;
int n, c, ans = 1e9 + 7;
int d[MAXC][MAXC];
int C[MAXN][MAXN];
int Arr[3][MAXC];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> c;
    for (int i = 0; i < c; i++)
        for (int j = 0; j < c; j++)
            cin >> d[i][j];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            cin >> C[i][j];
            C[i][j]--;
        }
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < c; j++) {
            for (int x = 0; x < n; x++)
                for (int y = 0; y < n; y++)
                    Arr[i][j] += ((x + y + 2) % 3 == i? d[C[x][y]][j]: 0);
        
        }
    for (int i = 0; i < c; i++)
        for (int j = 0; j < c; j++)
            for (int z = 0; z < c; z++)
                if (i != j && i != z && j != z)
                    ans = min(ans, Arr[0][i] + Arr[1][j] + Arr[2][z]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(){
  int a,b,c,tmp;
  
  scanf("%d%d%d",&a,&b,&c);
  
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(b<c){
    tmp=b;
    b=c;
    c=tmp;
  }
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  
  printf("%d",b+c);
  
  return 0;
}
  
  

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

class UnionFindTree {
private:
    vector<int> parent;
    vector<int> count;
public:
    UnionFindTree(int n) : parent(n), count(n, 1) {
        // 最初は全てを根として初期化
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int get_root(const int x) {
        // データxが属する木の根を取得する
        if (parent[x] == x) return x;
        // 取得したものは直接木の根をつなぐ(経路圧縮)
        return parent[x] = get_root(parent[x]);
    }

    void unite(const int x, const int y) {
        // xとyの木を併合する
        int rx = get_root(x);
        int ry = get_root(y);
        // 元から同じ木に属している場合は何もしない
        if (rx == ry) return;
        // xの属する木をyの属する木につける
        parent[rx] = ry;
        count[ry] += count[rx];
        count[rx] = 0;
    }

    bool is_same_root(const int x, const int y) {
        return get_root(x) == get_root(y);
    }

    int get_size(const int x) {
        return count[get_root(x)];
    }

    void print() {
        for(auto elm : parent) cout << elm << " ";
        cout << endl;
        for(auto elm : count) cout << elm << " ";
        cout << endl;
    }
};

int main(){
    int v, e; cin >> v >> e;
    map<int, vector<pair<int, int>>> g;
    for (auto i = 0; i < e; i++) {
        int s, t, w; cin >> s >> t >> w;
        g[w].emplace_back(s, t);
    }

    UnionFindTree tree(v); int64_t ans = 0;
    for (auto & vec : g) {
        for (auto & elm : vec.second) {
            if (not tree.is_same_root(elm.first, elm.second)) {
                tree.unite(elm.first, elm.second);
                ans += vec.first;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5452
#include <cstdio>

int n, a, b, sum;


int main(){
	while(~scanf("%d %d %d", &n, &a, &b)){
		sum = 0;
		for(int i = a; i <= n; i++){
			int t1, t2, t3, t4, t5, t6;
			t1 = i / 10000;
			t2 = (i - t1 * 10000) / 1000;
			t3 = (i - t1 * 10000 - t2 * 1000) / 100;
			t4 = (i - t1 * 10000 - t2 * 1000 - t3 * 100) / 10;
			t5 = i % 10;
			t6 = t1 + t2 + t3 + t4 + t5;
			if(t6 >= a && t6 <= b)
				sum += i;
		}
		printf("%d\n", sum);
	}
}

Measured memory_bytes: 128
function Main(input){
    a=input.split("");
    a.pop()
    var ans=true;
    for(var i=0;i<a.length;i++){
        if(i%2==0&&a[i]=="L")ans=false
        else if(i%2==1&&a[i]=="R")ans=false
    }
    if(ans)console.log("Yes")
    else console.log("No")
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <stdio.h>

#define N 8
#define NOT_FREE -1
#define FREE 1

int col[101],dpos[101],dneg[101],row[101],r,c,I[101];

void printBoard(void)
{
  int i,j;
  //printf("test\n");
  for(i = 0;i < N;i++)
    {
      for(j = 0;j < N;j++)
	{
	  if(row[i] == j)
	    {
	      printf("Q");
	    }
	  else
	    {
	      printf(".");
	    }
	}
      printf("\n");
    }
  
}

int putQueen(int i)
{
  int j;
  if(i == N)
    {
      printBoard();
      return 1;
    }
  /*if(row[i] != 9)
    {
      if(putQueen(i + 1) == 1)
	{
	  return 1;
	}
      return 0;
    }*/
  if(I[i] == NOT_FREE)
    {
      if(putQueen(i + 1) == 1)
	{
	  return 1;
	}
      return 0;
      }
  
  for(j = 0;j < N;j++)
    {
      if(col[j] == NOT_FREE || dpos[i + j] == NOT_FREE || dneg[i - j + N - 1] == NOT_FREE)
	{
	  continue;
	}
      row[i] = j; //put a queen at (i,j)
      col[j] = dpos[i + j] =dneg[i - j + N - 1] = NOT_FREE;
      if(putQueen(i + 1) == 1)
	{
	  return 1;
	}
      col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
  return 0;
}

int main()
{
  int i,k;

  for(i = 0;i< N;i++)
    {
      row[i] = 9;
    }

  for(i = 0; i< N;i++)
    {
      col[i] = dpos[r + c] = dneg[r - c + N - 1] = FREE;
    }

  scanf("%d",&k);

  for(i = 0;i < k;i++)
    {
      scanf("%d %d",&r,&c);
      I[r] = NOT_FREE;
      row[r] = c;
      col[c] = dpos[r + c] = dneg[r - c + N - 1] = NOT_FREE;
    }

  putQueen(0);
    
  return 0;
}



Measured memory_bytes: 2108
def solve(s):
    n = len(s)
    l = [0] * n # 何個先に"L"があるか
    r = [0] * n # 何個先に"R"があるか
    for i in range(1, n):
        if s[i-1] == "R":
            r[i-1] = 0
            r[i] = 1
        else:
            r[i] = r[i-1] + 1

    for i in range(n-2, -1, -1):
        if s[i+1] == "L":
            l[i+1] = 0
            l[i] = 1
        else:
            l[i] = l[i+1] + 1
    ans = [0] * n
    for i in range(n):
        if s[i] == "R":
            d = l[i]
            if d % 2 == 0:
                j = i + d
            else:
                j = i + d - 1
            ans[j] += 1
        else:
            d = r[i]
            if d % 2 == 0:
                j = i - d
            else:
                j = i - d + 1
            ans[j] += 1
    return " ".join(map(str, ans))

s = input()
print(solve(s))

Measured memory_bytes: 15220
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;


// 両端のXORが自身と等しいということは、両端と自身をXORすると0となる。
// xi, xi+1, xi+2, xi+3の4つの数を考える。Xi^Xi+1^xi+2 = xi+1^xi+2^xi+3よりxi=xi+3
// 3個区切りで同じ数字にする必要がある。xi+1やxi+2についても同様である。
// したがって、以下のように分類できる。
// 1. 異なる数字が4種類以上出現する場合は絶対に達成不可能
// 2. 異なる数字が3種類出現する場合は、それぞれの出現回数がn/3回ずつである
// 3. 異なる数字が2種類出現する場合は、0がn/3回、1以上の整数が2*n/3回
// 4. 0がn回出現する場合

int main(){
    Init();
    ll n; cin >> n;
    map<ll, ll> cnt;
    ll cnt_z = 0;
    rep(i, n){
        ll a; cin >> a;
        cnt[a]++;
        if(a == 0) cnt_z++;
    }
    // 上記の条件4.
    if(cnt_z == n) Yes();
    // 3の倍数じゃない場合や4種類以上の数字が出現する場合、2. 3.の達成が不可能
    else if(n%3 != 0 || cnt.size() >= 4) No();
    else{
        // 条件2.
        if(cnt.size() == 3){
            ll num = n/3;
            bool ans = true;
            ll calc = 0;
            for(auto &p: cnt){
                if(p.second != num) ans = false;
                calc ^= p.first;
            }
            if(calc) ans = false;
            ans ? Yes() : No();
        }
        // 条件3.
        else{
            ll num = n/3;
            bool ans = true;
            for(auto &p: cnt){
                if((p.first == 0 && p.second != num) || (p.first != 0 && p.second != num*2)) ans = false;
            }
            ans ? Yes() : No();
        }
    }
}

Measured memory_bytes: 8432
//18-2 すごろく
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#define LL long long
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while(true)

int main(){
    int N;
    int A[100];
    cin >> N;
    int ans = 1;
    int tmp = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i] == 1){
            tmp++;
            ans = max(ans,tmp+1);
        }
        else{
            tmp = 0;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  set<int> set;
  for (int i = a; i < a + k; ++i) {
    if (i > b) break;
    set.insert(i);
  }
  for (int i = b; i > b - k; --i) {
    if (i < a) break;
    set.insert(i);
  }
  for (int t : set) cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=102;
int n,a[3][N],dp[3][N];
int main()
{
    cin>>n;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
        cin>>a[i][j];
        memset(dp,0,sizeof(dp));
    dp[0][0]=a[0][0];
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            if(i==1)dp[i][j]=dp[i][j-1]+a[i][j];
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
            }
        }
    }
    cout<<dp[2][n]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define N 200005

int c[N];
int n,m;

int main()
{
    while(scanf("%d%d",&n,&m)==2)
    {
        int a,b,i;
        memset(c,0,sizeof(c));
        for(i=0;i<m;i++)
        {
            scanf("%d%d",&a,&b);
            if(a==1)
            {
                c[b]++;
            }
            if(b==n)
            {
                c[a]++;
            }
        }
        int j=0;
        for(i=1;i<n;i++)
        {
            if(c[i]==2)
            {
                j=1;
                break;
            }
        }
        if(j==1)
        {
            printf("POSSIBLE\n");
        }
        else
        {
            printf("IMPOSSIBLE\n");
        }
    }
    return 0;
}


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

int main() {
  int T[100], P[100][2];
  int N, M;
  int res = 0;
  cin >> N;

  for(int i = 0; i < N; i++) cin >> T[i];

  cin >> M;

  for (int i = 0; i < M; i++) cin >> P[i][0] >> P[i][1];

  for (int i = 0; i < M; i++) {
    res = 0;
    for (int j = 0; j < N; j++) {
      if (P[i][0] == j + 1) res += P[i][1];
      else res += T[j];
    }
    cout << res << endl;
  }
  return 0;
}


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

int main(){
   int n; cin>>n;
   vector<int> b(n);
   rep(i,n) cin>>b[i];
   sort(b.begin(),b.end());
   int ans=b[b.size()/2]-b[b.size()/2-1];
   cout<<ans<<endl;
   return 0;
}


   


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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1000000007;
const int INF = 1<<18;
const lint INFLINT = 1LL << 60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    
    vector<vector<int>> to(n);
    rep(i, n - 1) {
        to[i].push_back(i + 1);
        to[i + 1].push_back(i);
    }
    to[x].push_back(y);
    to[y].push_back(x);
    
    vector<vector<int>> cost(n, vector<int>(n, INF));
    
    rep(i, n) {
        queue<int> q;
        q.push(i);
        cost[i][i] = 0;
        
        while(!q.empty()) {
            int now = q.front(); q.pop();
            for(int next : to[now]) {
                if(cost[i][next] == INF) {
                    cost[i][next] = cost[i][now] + 1;
                    q.push(next);
                }
            }
        }
    }
    
    vector<int> ans(n);
    rep(i, n) {
        for(int j = i + 1; j < n; j++) {
            ans[cost[i][j]]++;
        }
    }
    
    for(int i = 1; i < n; i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(args...) do {cerr << #args << " : "; debug(args); } while(false)
#define all(v) ((v).begin()),((v).end())
#define size(x) (int) x.size() 
#define pb emplace_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
void debug () {cerr << endl;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template < typename T, typename ... hello>void debug( T arg, const hello &... rest) {cerr << arg << ' ';debug(rest...);}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    for(int t = 1; t <= T; t++){
		string x,y;
		cin >> x >> y;
		int count = 0;
		for(int i = 0;i < size(x); i++){
			if(x[i] != y[i]){
				count += 1;
			}
		}
		cout << count;
	}
}
 


Measured memory_bytes: 3784
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
   int n;
   cin>>n;
   int max=0,sum=0;
   rep(i,0,n){
      int p;
      cin>>p;
      sum+=p;
      if (max<p) max=p;
   }
   cout<<sum-max/2;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
vll s;
vll t;
//vll x;
ll solve(ll x){
    int sok = s.size();
    int sng = -1;
    while(abs(sok-sng)>1){
        int mid = (sok+sng)/2;
        if(s[mid]>=x){
            sok = mid;
        }else{
            sng = mid;
        }
    }
    int tok = t.size();
    int tng = -1;
    while(abs(tok-tng)>1){
        int mid = (tok+tng)/2;
        if(t[mid]>=x){
            tok = mid;
        }else{
            tng = mid;
        }
    }
    ll ret;
    ret = min({abs(x-s[sng])+abs(s[sng]-t[tng]),abs(x-s[sok])+abs(s[sok]-t[tng]),abs(x-s[sng])+abs(s[sng]-t[tok]),abs(x-s[sok])+abs(s[sok]-t[tok]),abs(x-t[tng])+abs(t[tng]-s[sng]),abs(x-t[tok])+abs(t[tok]-s[sng]),abs(x-t[tng])+abs(t[tng]-s[sok]),abs(x-t[tok])+abs(t[tok]-s[sok])});
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b, q;
    cin >> a >> b >> q;
    s.pb(-LLINF);
    t.pb(-LLINF);
    REP(i,a){
        ll tmp;
        cin >> tmp;
        s.pb(tmp);
    }
    REP(i,b){
        ll tmp;
        cin >> tmp;
        t.pb(tmp);
    }
    s.pb(LLINF);
    t.pb(LLINF);
    REP(i,q){
        ll x;
        cin >> x;
        cout << solve(x) << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
a=[str(i) for i in range(1,10)]
i=0
while len(a)<100000:
    if a[i][-1]!="0":
        a.append(a[i]+str(int(a[i][-1])-1))
    a.append(a[i]+str(int(a[i][-1])))
    if a[i][-1]!="9":
        a.append(a[i]+str(int(a[i][-1])+1))
    i+=1
# print(a[:30])
k=int(input())
print(a[k-1])

Measured memory_bytes: 80736
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin>>D;
    V<ll> c(26);
    V<ll> lst(26,1);
    cinf(26,c);
    V<P> p(26);
    //V<ll> t(D);
    set<P> st;
    ll sum=0;
    rep(i,26){
        p[i]=make_pair(c[i],i);
    }
    sort(all(p));
    ll s[D][26];
    rep(i,D){
        rep(j,26)cin>>s[i][j];
    }
    //cinf(D,t);
    V<ll> ans(D);
    ll now=0;
    rep(i,D){
        set<P> ss;
        ll cnt=-1;
        ll res=-1;
        rep(j,26){
            if(s[i][j]>res){
                res=s[i][j];
                cnt=j;
            }
            /*ll cc=0;
            rep(k,26){
                if(j==k) continue;
                cc+=lst[k]*c[k];
            }
            if(s[i][j]-cc>res){
                res=s[i][j]-cc;
                cnt=j;
            }*/
        }
        ll cc=0;
        rep(j,26){
            if(j!=cnt){
                cc+=c[j]*lst[j];
            }
        }
        now+=res-cc;
        cout<<cnt+1<<endl;
        lst[cnt]=1;
        rep(j,26){
            if(j!=cnt) lst[j]++;
        }
    }
    //cout<<ans[i]<<endl;
    /*rep(i,D) cout<<ans[i]+1<<endl;*/
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF 1000000000000000
#define MAXN (int)(1e5)+1
#define MOD 1000000007

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pwi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector< vector<pair<int,lli > > > wGraph;
typedef vector<vector<int> > graph;
//typedef vector<vector<lli> > matrix;

graph g(MAXN);

vector<int> dp(MAXN,-1);
int n;

void addAresta(int src,int dst){
	g[src].pb(dst);
}

int knap(int i){

	if(i>n){
		return 0;
	}

	if(dp[i]!=-1) return dp[i];

	int ma = 0;
	for(auto k:g[i]){
		ma = max(ma,knap(k)+1);
		//cout<<"de "<<i<<" para "<<k<<" == "<<ma<<endl;
	}
	return dp[i] = ma;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(7);

    int m;
    cin>>n>>m;
    int sor;

    for(int i = 0;i<m;++i){
    	int src,dst;
    	cin>>src>>dst;
    	addAresta(src,dst);
    }

    int ma = 0;
    for(int i = 1;i<=n;++i){
    	ma = max(ma,knap(i));
    }

    cout<<ma<<endl;

    return 0;

}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,l,ans=0,sum=0,lar=INT_MAX,res;
    cin>>n>>l;
    ll arr[n];
    for(i=0;i<n;i++){
        arr[i]=l+i;
        ans+=arr[i];
        sum+=arr[i];
    }
    for(i=0;i<n;i++){
        ans-=arr[i];
        if(abs(ans-sum)<lar){
            lar=abs(ans-sum);
            res=arr[i];
        }
        ans=sum;
    }
    cout<<sum-res<<endl;
    return 0;
}


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


int main (){
    int a ,b;
    cin >> a >> b;

    int min , max;
    if ( a >= b){ 
        min =b; 
        max =a;
    }

    else {
        min = a; 
        max= b;
    }

    for (int i =0 ; i<max ; i++ )
        cout << min;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll MOD = 1000000007;
const int MAX = 4001;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n,k;
    cin >> n >> k;
    COMinit();
    rep(i,k){
        cout << COM(n-k+1, i+1) * COM(k-1, i) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 3708
n = int(input())
bs = list(map(int, input().strip().split()))

as_ = [0] * n

for i in range(n):
    if i == 0:
        as_[i] = bs[i]
    elif i < n - 1:
        as_[i] = min(bs[i - 1], bs[i])
    else:
        as_[i] = bs[i - 1]

print(sum(as_))


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int find(int n,int x)
{if(n<x)
 return 0;
 else
 return n/x+find(n/x,x);
}
int main()
{int f[1001];
 int i,j;
 for(i=1;i<1001;i++)
 f[i]=1;
 for(i=2;i<1001;i++)
 {if(f[i]==1)
  {for(j=i+i;j<1001;j+=i)
   f[j]=0;
  }
 }
 int n;
 while(~scanf("%d",&n))
 {long long sum=1;
  for(i=2;i<=n;i++)
  {if(f[i])
   {sum*=(find(n,i)+1);
    sum%=(10*10*10*10*10*10*10*10*10+7);
   }
  }
  printf("%lld\n",sum%(10*10*10*10*10*10*10*10*10+7));
 }
 return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a < b && b < c){
			System.out.printf("Yes\n");
		}else{
			System.out.printf("No\n");
		}
	}
}



Measured memory_bytes: 26436
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
long long a[N],b[N],c[N];
int main()
{
	int n,m;
	scanf("%d%d%lld",&n,&m,&a[1]);
	long long sum=0;
	for(int i=2;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]>a[i-1])
		{
			sum+=a[i]-a[i-1];
			b[a[i-1]+1]+=a[i-1]+1;
			b[a[i]+1]-=a[i-1]+1;
			c[a[i-1]+1]++;
			c[a[i]+1]--;
		}
		else
		{
			sum+=m-a[i-1]+a[i];
			b[a[i-1]+1]+=a[i-1]+1;
			c[a[i-1]+1]++;
            b[1]-=m-a[i-1]-1;
            c[1]++;
            b[a[i]+1]+=m-a[i-1]-1;
            c[a[i]+1]--;
		}
	}
	for(int i=1;i<=m;i++)
		b[i]+=b[i-1],c[i]+=c[i-1];
	long long ans=0;
	for(int i=1;i<=m;i++)
		ans=max(ans,i*c[i]-b[i]);
	printf("%lld\n",sum-ans);
	return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N);
	for(auto &i:A)cin >> i;
	for(auto &i:B)cin >> i;
	for(auto &i:C)cin >> i;
	int ans=0;
	for(int i=0;i<N;i++){
		ans+=B[A[i]-1];
		if(i>0 && A[i]-A[i-1]==1)ans+=C[A[i-1]-1];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<char> vec(W);

    for (int i = 0; i < H; ++i) {
        // input
        for (int k = 0; k < W; ++k) {
            cin >> vec.at(k);
        }

        // output
        if (i == 0) {
            for (int j = 0; j < W + 2; ++j) {
                cout << "#";
            }
            cout << endl;
        }
        cout << "#";

        for (int l = 0; l < W; ++l) {
            cout << vec.at(l);
        }
        
        cout << "#" << endl;
        if (i == H - 1) {
            for (int j = 0; j < W + 2; ++j) {
                cout << "#";
            }
            cout << endl;
        }

    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;

int main(void) {
	int x, a, b;
	int p, q;
	cin >> x >> a >> b;
	if (x - a > 0) {
		p = x - a;
	}
	else {
		p = a - x;
	}
	if (x - b > 0) {
		q = x - b;
	}
	else {
		q = b - x;
	}
	if (p > q) {
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}
	return 0;
}

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

int main() {
    int N, A, B;

    cin >> N >> A >> B;

    int res = 0;
    for (int n=1; n<=N; n++) {
        int target_num = n;

        // 各桁の和を計算する
        int sum = 0;
        while (true) {
            int remaind = target_num % 10;
            if (remaind != 0) {
                // 最下位桁を加算する
                sum += remaind;
            }
            target_num /= 10;

            if (target_num == 0) break;
        }

        // 各桁の和がA以上B以下の判定
        if (A <= sum && sum <= B)   res += n;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ull powmod(ull  a,ull b, ull mod) {
  ull res=1;
  for(; b; b >>= 1){
    if(b & 1){
      res = res * a % mod;
    }
    a = a * a % mod;
  }
  return res;
}

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

  ull m, n;
  cin >> m;
  cin >> n;

  ull res;
  res = powmod(m, n, 1000000007);

  cout << res << "\n";
}



Measured memory_bytes: 3204
import math, cmath

def koch(p1, p2, n):
    if n == 0:
        return [p1, p2]
    
    rad60 = math.pi/3
    v1 = (p2 - p1)/3
    v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
    q1 = p1 + v1
    q2 = q1 + v2
    q3 = q1 + v1
    if n == 1:
        return [p1,q1,q2,q3,p2]
    else:
        x1 = koch(p1,q1,n-1)[1:-1]
        x2 = koch(q1,q2,n-1)[1:-1]
        x3 = koch(q2,q3,n-1)[1:-1]
        x4 = koch(q3,p2,n-1)[1:-1]
        x = [p1]+x1+[q1]+x2+[q2]+x3+[q3]+x4+[p2]
    return x

n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)

for e in koch(p1,p2,n):
    print e.real,e.imag

Measured memory_bytes: 4660
#include<stdio.h>
int main()
{
    int a,b,c,sum;
    while(scanf("%d %d %d",&a,&b,&c)!=EOF)
    {
        if(a>b)
        {
            int t=a;
            a=b;
            b=t;
        }
        if(b>c)
        {
            int t=b;
            b=c;
            c=t;
        }
        if(a>b)
        {
          int t=a;
            a=b;
            b=t;
        }
    sum=a+b;
    printf("%d",sum);
    }

    return 0;

}


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

int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        if((i+1)%2==1){
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
                cout<<"No"<<endl;
                return 0;
            }

        }else{
            if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	int x;
	cin >> x;
	int y = x / 500 * 1000 + x % 500 / 5 * 5;
	cout << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
  int n;
  cin >> n;
  ll a[n];
  for (int i= 0; i<n; i++){
    cin >> a[i];
  }
  ll sum = 0;
  ll sum2 = 0;
  ll count1  = 0;
  ll count2 = 0;
  int plus_minus_flag = 1;
  	for (int i = 0; i<n; i++){
      sum += a[i];
      if (plus_minus_flag && sum > 0) {plus_minus_flag = 0;}
      else if (plus_minus_flag && sum <= 0){
       	//sum -= a[i];
        count1 += 1-sum;
        sum = 1;
        plus_minus_flag = 0;
      }
      else if (!plus_minus_flag && sum>=0){
        //sum -= a[i];
        count1 += sum+1;
        sum = -1;
        plus_minus_flag = 1;
      }
      else if (!plus_minus_flag && sum < 0) {plus_minus_flag = 1;}
      //cout << "i: "<< i << "sum:"<< sum << "count1:"<<count1 << endl;
  }
  plus_minus_flag = 0;
  for (int i = 0; i<n; i++){
      sum2 += a[i];
      if (plus_minus_flag && sum2 > 0) {plus_minus_flag = 0;continue;}
      else if (plus_minus_flag && sum2 <= 0){
        //sum2 -= a[i];
        count2 += 1-sum2;
        sum2 = 1;
        plus_minus_flag = 0;
      }
      else if (!plus_minus_flag && sum2>=0){
        //sum2 -= a[i];
        count2 += sum2+1;
        sum2 = -1;
        plus_minus_flag = 1;
      }
      else if (!plus_minus_flag && sum2 < 0) {plus_minus_flag = 1; continue;}
  }
  cout << min(count1, count2) << endl;
}

Measured memory_bytes: 1024
require 'prime'

def f(n,ps)
	res=[]
	m=n
	ps.each{|p|
		c=0
		while (n%p==0) 
			n=n/p
			c+=1
		end
		if(c>0)
			$arr[p]+=c
		end
	}
	res
end

def f2(p,m,c)

	if m>75 || c>3 then
		0
	elsif m==75
		1
	elsif p>=$ps.size
		0
	elsif $ps[p]>50
		0
	else
		res=0
		[2,4,14,24,74].each{|e|
			if $arr[$ps[p]]>=e then
				res+=f2(p+1,m*(e+1),c+1)
			end
		}
		res+=f2(p+1,m,c)
		res
	end
end

n=gets.to_i
$ps=Prime.each(n).to_a
$arr=Hash.new(0)

(2..n).each{|e|
	f(e,$ps)
}
if (n<2) then
	puts 0
else
	puts f2(0,1,0)
end

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

int main(){
    string str = "No";
    int N;
    cin >> N;
    vector<pair<int, int>> p(N);
    int count = 0;
    for (int i = 0; i < N; i++){
        cin >> p[i].first;
        cin >> p[i].second;
        if (p[i].first == p[i].second){
            count++;
            if(count>=3){
                str = "Yes";
            }
        }else{
            count = 0;
        }
    }

    cout << str << endl;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

vector<int> childs[1005];
vector<string> msg(1005);

void dfs(int x, int d) {
    rep(i, 0, d) cout << '.';
    cout << msg[x] << endl;
    for (int h : childs[x]) dfs(h, d + 1);
}

int x[10][10];

int op(int a, int b) {
    return x[a][b];
}

int check(int a, int b, int c, int d) {
    return op(op(op(op(0, a), b), c), d);
}
int check2(int a, int b, int c, int d, int e) {
    int v = op(op(op(op(op(0, a), b), c), d), e);
    // if (!v) {
    //     printf("%d%d%d%d%d\n", a, b, c, d, e);
    // }
    return v;
}

bool ok(string x, string y, string tgt) {
    int n = x.length();
    int p = 0, q = 0, z = 0;
    while (z < n) {
        if (z % 2 == 0) {
            while (p < n && x[p] != tgt[z]) p++;
            if (p >= n) {
                return 0;
            }
            p++;
        } else {
            while (q < n && y[q] != tgt[z]) q++;
            if (q >= n) {
                return 0;
            }
            q++;
        }
        z++;
    }
    return 1;
}

int main() {
    string x, y; cin >> x >> y;
    cout << (ok(x, y, x) || ok(y, x, x) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3276
import math
k = int(input())
wa = 0
for a in range(k):
    wa += (a + 1)
for a in range(k):
    for b in range(k):
        if a != b:
            wa += 3 * math.gcd(a + 1, b + 1)


for a in range(k):
    for b in range(a):
        for c in range(b):
            wa += 6*math.gcd(math.gcd(a+1, b+1), c+1)
print(wa)

Measured memory_bytes: 68080
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;

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

static const int MAX = 100005;
static const int INFTY = 9023372036854775807;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int>> adj[MAX];
int dist[MAX];

void dijkstra(int firstN) {
	priority_queue<pair<int, int>> PQ;
	int color[MAX];
	
	REP(i, n + 1) {
		dist[i] = INFTY;
		color[i] = WHITE;
	}

	dist[firstN] = 0;
	PQ.push(make_pair(0, firstN));
	color[firstN] = GRAY;

	while (!PQ.empty()) {
		pair<int, int> f = PQ.top(); PQ.pop();
		int u = f.second;
		color[u] = BLACK;

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

		REP(j, adj[u].size()) {
			int v = adj[u][j].first;
			if (color[v] == BLACK) continue;
			if (dist[v] > dist[u] + adj[u][j].second) {
				dist[v] = dist[u] + adj[u][j].second;
				PQ.push(make_pair(dist[v] * (-1), v));
				color[v] = GRAY;
			}
		}
	}

	/*REP(i, n) {
		cout << i + 1 << " " << (dist[i + 1] == INFTY ? -1 : dist[i + 1]) << endl;
	}*/
}

signed main() {
	int u, v, c;
	cin >> n;
	REP(i, n - 1) {
		cin >> u >> v >> c;
		adj[u].push_back(make_pair(v, c));
		adj[v].push_back(make_pair(u, c));
	}

	int Q, K;
	cin >> Q >> K;

	dijkstra(K);

	int x, y;
	REP(i, Q) {
		cin >> x >> y;
		cout << dist[x] + dist[y] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)

int H,W;

int fie[2020][2020];

int ps[2020][2020];
int hes[2020][2020];
int wes[2020][2020];
int es[2020][2020];

int main(){
  cin >> H >> W;
  int Q;
  cin >> Q;
  rep(i,1,H){
    string s;
    cin >> s;

    rep(j,1,W){
      fie[i][j] = (int)s[j - 1] - '0';
      ps[i][j] = fie[i][j];
    }
  }

  rep(i,1,H) rep(j,1,W) ps[i][j] += ps[i - 1][j];
  rep(i,1,H) rep(j,1,W) ps[i][j] += ps[i][j - 1];


  rep(i,1,H) rep(j,1,W){
    hes[i][j] = hes[i - 1][j];
    if(fie[i - 1][j] && fie[i][j]){
      hes[i][j]++;
    }
  }
  rep(i,1,H) rep(j,1,W){
    hes[i][j] += hes[i][j - 1];
  }
  rep(i,1,H) rep(j,1,W){
    wes[i][j] = wes[i][j - 1];
    if(fie[i][j - 1] && fie[i][j]){
      wes[i][j]++;
    }
  }
  rep(i,1,H) rep(j,1,W){
    wes[i][j] += wes[i - 1][j];
  }

  rep(c,1,Q){
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--;
    y1--;
    int pt = ps[x2][y2] + ps[x1][y1] - ps[x2][y1] - ps[x1][y2];
    int het = hes[x2][y2] + hes[x1 + 1][y1] - hes[x2][y1] - hes[x1 + 1][y2];
    int wet = wes[x2][y2] + wes[x1][y1 + 1] - wes[x2][y1 + 1] - wes[x1][y2];

    cout << pt - het - wet << endl;
  }
}


Measured memory_bytes: 67072