akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x); cout<<#x<<"="<<x<<endl;
#define watch2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define endl "\n"
#define int long long
using namespace std;    

long long inverseMod(long long x,long long mod);
long long nCr(long long n,long long r,long long mod){
    //when r is lesser and is greater
    long long res=1;
    if(r>n-r)r=n-r;
    long long div=1;
    for(long long  i=0;i<r;i++){
        res=(res*(n-i))%mod;
    }

    for(long long i=1;i<=r;i++){
        div=(div*i)%mod;
    }
    return (res*inverseMod(div,mod))%mod;
}


long long power(long long x,long long n,long long mod){
//(x^n)%mod
long long result=1;

    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

long long inverseMod(long long x,long long mod){

return power(x,mod-2,mod);
}



int32_t main(){

    fast
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC";
    else cout<<"ABC";


    return 0;
}



Measured memory_bytes: 3652
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	l := 0
	fmt.Println(l)
	var ls string
	fmt.Scan(&ls)
	if ls == "Vacant" {
		return
	}

	r := n - 1
	fmt.Println(r)
	var rs string
	fmt.Scan(&rs)
	if rs == "Vacant" {
		return
	}

	for {
		m := (l + r) / 2
		fmt.Println(m)
		var ms string
		fmt.Scan(&ms)
		if ms == "Vacant" {
			return
		}

		if v := (r - m) % 2; (v == 1 && rs == ms) || (v == 0 && rs != ms) {
			l = m
			ls = ms
		} else if v := (m - l) % 2; (v == 1 && ms == ls) || (v == 0 && ms != ls) {
			r = m
			rs = ms
		}
	}
}


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

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

  int ans;

  ans = ( (A * 3) + P ) / 2;

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int ini[3], a[3], b[3];
	int ans = 0;

	for (int i = 0; i < 3; i++)
	{
		scanf("%d", &ini[i]);
		a[i] = ini[i];
	}

	for (int i = 0; i < 10000000; i++)
	{
		if (a[0] % 2 == 1 || a[1] % 2 == 1 || a[2] % 2 == 1)	break;

		b[0] = (a[1] + a[2]) / 2;
		b[1] = (a[2] + a[0]) / 2;
		b[2] = (a[0] + a[1]) / 2;

		if (b[0] == ini[0] && b[1] == ini[1] && b[2] == ini[2])
		{
			ans = -1;
			break;
		}
		
		a[0] = b[0]; a[1] = b[1]; a[2] = b[2];

		ans++;
	}
	
	printf("%d", ans);
	return 0;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,s,t) for(auto (i) = (s); (i) <= (t); ++(i))
#define repD(i,t,s) for(auto (i) = (t); (i) >= (s); --(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

template<class T> T rem(T n, T m){ return (n % m + m) % m; }

template<class T> T gcd(T a, T b){ if(a % b){ return gcd(b, a % b); }else{ return b; } }

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll a,b,c,d,t; cin>>t;
	rep(i,t){
		cin>>a>>b>>c>>d;
		if(a < b || d < b) cout<<"No\n";
		else{
			ll g = gcd(b,d);
			ll r = a % g;
			ll x = c % g; 
			ll y = c + rem(r - x,g);
			if(y == c) y += g;
			if(y < b) cout<<"No\n";
			else cout<<"Yes\n";
		}
	}
	
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	string A,B; cin>>A>>B;
	if(A.size() > B.size())cout<<"GREATER";
	else if(A.size() < B.size())cout<<"LESS";
	else {
		for(int i = 0; i < A.size(); i++){
			if(A[i] > B[i]){
				cout<<"GREATER";
				break;
			}
			else if(A[i] < B[i]){
				cout<<"LESS";
				break;
			}
			if(i == A.size() - 1 && A[i] == B[i]){
				cout<<"EQUAL";
				break;
			}
		}

	}
}


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

int main() {
    int W, Q;
    while (cin >> W >> Q, W || Q) {
        vector<int> used(W+1, -1);
        vector<int> cat(Q);

        for (int i = 0; i < Q; i++) {
            char c;
            cin >> c;
            if (c == 'w') {
                int n;
                cin >> n;
                int car = cat[n];
                while (used[car] == n) used[car] = -1, car++;
            } else {
                int s, w;
                cin >> s >> w;

                bool flag = false;
                for (int i = 0; !flag && i < W-w+1; i++) {
                    if (used[i] != -1) continue;

                    bool f = true;
                    for (int j = 0; f && j < w; j++) {
                        if (used[i+j] != -1) f = false;
                    }
                    if (f) {
                        flag = true;
                        cat[s] = i;
                        cout << i << endl;

                        for (int j = 0; j < w; j++) {
                            used[i+j] = s;
                        }
                    }
                }
                if (!flag) cout << "impossible" << endl;
            }
        }

        cout << "END" << endl;
    }

    return 0;
}

Measured memory_bytes: 2996
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n;
	double x[15],y[15];
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf %lf",&x[i],&y[i]);
	}
	double sum,m=0;
	int a[15];
	for(int i=1;i<=n;i++) a[i]=i;
	int k=0;
	do{
		sum=0;
		for(int i=2;i<=n;i++){
			sum+=sqrt((x[a[i-1]]-x[a[i]])*(x[a[i-1]]-x[a[i]])+(y[a[i-1]]-y[a[i]])*(y[a[i-1]]-y[a[i]]));
		}
		k++;
		m+=sum;
	}while(next_permutation(a+1,a+n+1));
	printf("%.10lf\n",m*1.0/k);
	return 0;
}

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

int gcd(int x, int y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q);
    vector<int> r(q);
    rep(i, q) cin >> l[i] >> r[i];

    vector<int> ruiseki(n);
    ruiseki[0] = 0;
    int flag = (s[0] == 'A') ? 1 : 0;
    for (int i = 1; i < n; i++) {
        if (flag == 1 && s[i] == 'C') {
            ruiseki[i] += ruiseki[i - 1] + 1;
            flag = 0;
        }
        else {
            ruiseki[i] = ruiseki[i - 1];
            if (s[i] == 'A')
                flag = 1;
            else
                flag = 0;
        }
    }

    rep(i, q) cout << ruiseki[r[i] - 1] - ruiseki[l[i] - 1] << endl;

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

#define int long long

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

struct node {
    int prev, len;
};

string A;

node dp[220000][26];

signed main() {
    cin >> A;
    for (int i = 0; i < 26; i++) {
        dp[A.size()][i] = {i, 0};
    }
    for (int i = A.length() - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            dp[i][j] = {j, dp[i + 1][j].len};
        }
        int cur = A[i] - 'a';
        int min_len = 1145141919, min_prev;
        for (int j = 0; j < 26; j++) {
            if (dp[i + 1][j].len < min_len) {
                min_len = dp[i + 1][j].len;
                min_prev = j;
            }
        }
        dp[i][cur] = {min_prev, min_len + 1};
    }

    int min_len = 1145141919, min_start;
    for (int i = 0; i < 26; i++) {
        if (dp[0][i].len < min_len) {
            min_len = dp[0][i].len;
            min_start = i;
        }
    }

    for (int i = 0; i < A.length(); i++) {
        int next = dp[i][min_start].prev;
        if (dp[i][min_start].len != dp[i + 1][next].len) {
            cout << (char)(min_start + 'a');
        }
        min_start = next;
    }
    cout << (char)(min_start + 'a') << endl;
    return 0;
}

Measured memory_bytes: 82436
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii Dir[8] = { //?????????
	{ 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 },
	{ 1,1 },{ 1,-1 },{ -1,-1 },{ -1,1 }
};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}

signed main() {	
	char str [100001];

	scanf("%s", str);
	bool same = 0;
	if (str[0] == str[strlen(str) - 1]) {
		same = 1;
	}

	if (strlen(str) % 2) {
		printf(same ? "Second\n" : "First\n");
	}
	else {
		printf(same ? "First\n" : "Second\n");
	}
	return 0;
}

Measured memory_bytes: 384
def main():
    N,K = map(int,input().split())
    A = [0] + list(map(int,input().split()))
    
    i = 1
    pas = [i]
    pas_set = set(pas)
    k = 1
    while k <= K:
        if A[i] in pas_set:
            rps = pas.index(A[i])
            ans = A[i]
            break
        pas.append(A[i])
        pas_set.add(A[i])
        ans = A[i]
        i = A[i]
        k += 1

    if k >= K:
        print(ans)
    else:
        rpnum = (K-rps)%(k-rps)
        print(pas[rps+rpnum])

main()

Measured memory_bytes: 32208
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
const int N = 2e5 + 5 ;
int n, a[N], val[N], ans[N];
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	n = read<int>() ;
	for( ri i = 1; i <= n; ++i )
		val[i] = read<int>() ;
	for( ri i = 0; i <= 29; ++i ) {
		for( ri j = 1; j <= n; ++j )
			a[j] = ( val[j] >> i ) & 1 ;
		int sum = 0 ;
		for( ri j = 1; j <= n; ++j )
			sum += a[j] == 1 ;
		for( ri j = 1; j <= n; ++j ) {
			int tmp = sum - ( a[j] == 1 ) ;
			tmp %= 2 ;
			if( ( a[j] == 0 && tmp != a[j] ) || ( a[j] == 1 && tmp == a[j] ) )
				ans[j] += 1 << i ;
		}
	}
	for( ri i = 1; i <= n; ++i )
		print( ans[i] ), putchar( ' ' ) ;
	puts( "" ) ;
	cerr << 1. * clock() / CLOCKS_PER_SEC << "\n" ;
	return 0;
}

Measured memory_bytes: 5988
array = []

for count in 1..10
	array.push gets.chomp.to_i
end

count = 1

while count < 10
	if array[count-1] < array[count]
		spare = array[count-1]
		array[count-1] = array[count]
		array[count] = spare
		count = 1
		else
		count += 1
	end
end	

puts array[0..2]

Measured memory_bytes: 6096
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  int m;
  cin>>m;
  bool ans=false;
  string str;
  rep(i,m){
    cin>>str;
    rep(j,n)if(str==s[j]){
      if(ans){
	cout<<"Closed by "<<str<<endl;
	ans=false;
	goto END;
      }else{
	cout<<"Opened by "<<str<<endl;
	ans=true;
	goto END;
      }
    }
    cout<<"Unknown "<<str<<endl;
  END:;
  }
}

Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	int K = Integer.parseInt(scan.next());
	int X = Integer.parseInt(scan.next());
	int Y = Integer.parseInt(scan.next());

	int cost = (N <= K ? N * X : K*X + (N-K)*Y);
	System.out.println(cost);
	scan.close();
    }
}


Measured memory_bytes: 21844
import java.util.*;

class process {

	private String name;
	private int time;
	
	public process(String name,int time){
		this.name = name;
		this.time = time;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setTime(int time) {
		this.time = time;
	}

	public int getTime() {
		return time;
	}
}

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();

		ArrayList<process> ar = new ArrayList<process>();
		ArrayList<process> result = new ArrayList<process>();
		
		for (int i = 0; i < n; i++){
			ar.add(new process(sc.next(),Integer.parseInt(sc.next())));
		}
		
		int LapsedTime = 0,i = 0;
		process p;
		
		while(true){
			if(i < n){
				if((p = ar.get(i)).getTime() - q <= 0){
					LapsedTime += p.getTime();
					result.add(new process(p.getName(),LapsedTime));
					ar.remove(i);
					n--;
				} else {
					LapsedTime += q;
					p.setTime(p.getTime() - q);
					i++;
				}
			} else {
				i = 0;
			}
			if (n == 0){
				break;
			}
		}
		for(process r:result) {
			System.out.println(r.getName() + " " + String.valueOf(r.getTime()));
		}
	}
}

Measured memory_bytes: 12000
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    MOD = 1000000007

    N, M = map(int, input().split())
    A = set()
    for _ in range(M):
        a = int(input())
        A.add(a)

    dp = [0] * (N + 1)
    dp[0] = 1
    for i in range(1, N + 1):
        if i not in A:
            if i == 1:
                dp[i] = dp[i - 1]
            else:
                dp[i] = dp[i - 1] + dp[i - 2]

    # print(dp)
    ans = dp[N] % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 460404
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

string s;
ll n;

int main()
{
    cin>>s;
    n = s.size();
    if((s[0] == s[n - 1]) ^ (n % 2 == 0)) printf("Second\n");
    else printf("First\n");
    return 0;
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    string t;
    cin >> t;
    rep(i, t.size()) {
        if (t[i] == '?') t[i] = 'D';
    }
    out(t);

    return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) ||
		(s[0] == s[2] && s[1] == s[3] && s[0] != s[3]) ||
		(s[0] == s[3] && s[2] == s[1] && s[1] != s[3])) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

int main(){

	int A,B,C;
	cin >> A >> B >> C;

	if(B >= A*C){
		cout << C<< endl;
	}
	else{
		cout << B / A << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int ret = 0;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        if (s.size() % 2 == 1)ret++;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; ++i) {
    string tmp;
    cin >> tmp;
    mp[tmp]++;
  }

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3656
"""
E
"""
mod=10**9+7
MAX=4*10**5+100

g1=[1,1]
for i in range(2,MAX+1):
    num_1=g1[-1]*i%mod
    g1.append(num_1)
    
def cmb(n,r):
    return g1[n]*pow(g1[r],mod-2,mod)*pow(g1[n-r],mod-2,mod)%mod


N,K=map(int,input().split())

ans=cmb(2*N-1,N)


if K>=N:
    print(ans)
    
else:
    num=cmb(N,N-K-1)
    S=0
    for i in range(N-K-1,0,-1):
        S=(S+cmb(N-1,i-1)*cmb(N,i))%mod
        
    ans=(ans-S)%mod
    print(ans)

Measured memory_bytes: 66156
#define _CRT_SECURE_NO_WARINGS
#include<iostream>
#include<iomanip>
#include<map>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<fstream>
#include<map>
#include<unordered_map>
using namespace std;
typedef int me;
typedef long long ll;
typedef unsigned long long ull;
#define andrew  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define sz(v)(int)(v.size())
#define all(v) v.begin(),v.end()
#define PI 3.1415926535
#define sin(i) (long double)sin(i*PI/180.0);
#define OO 1e18;
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }
void the_end() {
#ifndef ONLINE_JUDGE;
	system("pause");
#endif
}
int dy8[] = { 0,0,1,-1,1,-1,-1,1 };
int dx8[] = { 1,-1,0,0,1,-1,1,-1 };
int id8[] = { 0, 1,2,3,4, 5,6, 7 };
// you can be specialist 
// soon will be (Cyain)
ll n;
struct One
{
	ll a;
	ll b;
	ll c;
};
vector<One>v;
ll mm[100005][3];
ll solve(int i, int prev)
{
	if (i == n+1)
		return 0;

	ll& ret = mm[i][prev];
	if (ret != -1)
		return ret;
	ret = 0;
	if (prev != 0)
		 ret = max(ret, solve(i + 1, 0)+v[i].a);

	if (prev != 1)
		 ret = max(ret,solve(i + 1, 1)+v[i].b);

	if (prev != 2) 
		ret = max(ret,  solve(i + 1, 2)+v[i].c);
	

	return mm[i][prev] = ret;
}
int main()
{
	andrew;
	cin >> n;
	v.resize(n+1);
	memset(mm, -1, sizeof(mm));
	for (int i = 1; i <= n; i++)
		cin >> v[i].a >> v[i].b >> v[i].c;
	cout << solve(0, 3) << endl;;
	the_end();
}

Measured memory_bytes: 9848
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll N,A[ll(1e5+5)];

ll mergecount(vector<ll> &a) {
  ll count = 0;
  ll n = a.size();
  if (n > 1) {
    vector<ll> b(a.begin(), a.begin() + n/2);
    vector<ll> c(a.begin() + n/2, a.end());
    count += mergecount(b);
    count += mergecount(c);
    for (ll i = 0, j = 0, k = 0; i < n; ++i)
      if (k == c.size())       a[i] = b[j++];
      else if (j == b.size())  a[i] = c[k++];
      else if (b[j] <= c[k])   a[i] = b[j++];
      else                   { a[i] = c[k++]; count += n/2 - j; }
  }
  return count;
}

int main(){
	cin>>N;
	rep(i,N){
	  cin>>A[i];
	}
	vector<ll> v(N),sum(N+1);
	ll left = 0, right= 1e10;
  ll mid,ans,ret;
  while (right!=left+1) {
        mid =(right+left)/2;
        rep(i,N){
        	v[i]=(A[i]>=mid)?1:-1;
        }
        FOR(i,1,N+1){
        	sum[i]=sum[i-1]+v[i-1];
        }
  			ans=mergecount(sum);
  			ans=N*(N+1)/2-ans;
        if((N*(N+1)/2+1)/2<=ans){
        	left=mid;
        	ret=mid;
        }else right=mid;
    }
	cout<<ret<<endl;
}

Measured memory_bytes: 4212
def answer(s: str) -> str:
    for i, c in enumerate(s):
        if i % 2 == 0:
            if c == 'L':
                return 'No'
        else:
            if c == 'R':
                return 'No'

    return 'Yes'


def main():
    s = input()
    print(answer(s))


if __name__ == '__main__':
    main()

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main(){ _

	int n, m; cin >> n >> m;
	vector<vector<int>> g(n);
	for(int i=0; i<m; i++) {
		int a, b; cin >> a >> b; a--, b--;
		g[a].push_back(b);
	}

	vector<int> dist(n, -1);
	function<int(int)> dfs = [&] (int x) {
		if(dist[x] != -1) return dist[x];
		dist[x] = 0;
		for(auto u : g[x])
			dist[x] = max(dist[x], dfs(u)+1); 
		return dist[x];
	};

	for(int i=0; i<n; i++) if(dist[i] == -1) dfs(i);

	cout << *max_element(dist.begin(), dist.end()) << endl;

	return 0;
}


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

int k(int v){
  int sum=0;
while(v){sum+=v%10;v/=10;}
  return sum;
}

int main(){
int n,a,b,c=0;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
  if(k(i)>=a&&k(i)<=b){c+=i;}
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {

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

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

        int ans = 0;

        while (a >= b) {
            b *= 2;
            ans++;
        }

        while (b >= c) {
            c *= 2;
            ans++;
        }

        if (ans <= k) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();

    }

}

Measured memory_bytes: 35672
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  using cd=complex<double>;
  vector<cd>p(n);
  rep(i,n){
    ll x,y;cin>>x>>y;
    p[i].real(x);
    p[i].imag(y);
  }
  double su=0;
  rep(i,n)repi(j,i+1,n){
    su+=abs(p[i]-p[j]);
  }
  cout<<setprecision(12)<<su/n*2<<endl;

  return 0;

}


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

int Stack[1000];
int top;

void push(int x){
    Stack[++top] = x;
}

int pop(void){
    top--;
    return Stack[top+1];
}

int main(void){
    top = 0;
    char input[100];
    int a, b;

    while (scanf("%s", input)!= EOF){
        switch (input[0]){
            case '+':
                b = pop();
                a = pop();
                push(a+b);
                break;
            case '-':
                b = pop();
                a = pop();
                push(a-b);
                break;
            case '*':
                b = pop();
                a = pop();
                push (a*b);
                break;
            default:
                push(atoi(input));
                break;
        }
    }

    printf("%d\n", pop());

    return 0;
}

Measured memory_bytes: 1800
a=input();b='';l='';f=0
for _ in range(int(input())):
    k=list(input().split())
    if k[0]=='1':
        f=(f+1)%2
    else:
        if (k[1]=='1' and f==0) or (k[1]=='2' and f==1):
            b+=k[2]
        else:
            l+=k[2]
p=b[::-1]+a+l
print(p if f==0 else p[::-1])

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

int main() {
  int N, from, to;
  int count = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> from >> to;
    count += to - from + 1;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> A(n + 1);
  vector<ll> B(m + 1);

  rep (i, n) {
    int p; cin >> p;
    A[i + 1] = A[i] + p;
  }
  rep (i, m) {
    int q; cin >> q;
    B[i + 1] = B[i] + q;
  }

  ll ans = 0;
  for (int i = 0; i < n + 1; i++) {
    if (A[i] > k) {
      continue;
    }
    ans = max(ans, (ll)(upper_bound(B.begin(), B.end(), k - A[i]) - B.begin() + i - 1));
  }

  cout << ans << endl;

  return 0;
}


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

ll solve(int n, int k, vector<ll> vi) {
    int popCount = min(n, k);
    ll ans = 0;
    for (int i = 0; i <= popCount; i++) {
        for (int j = 0; j <= popCount - i; j++) {
            vector<int> arr(i + j);
            copy(vi.begin(), vi.begin() + i, back_inserter(arr));
            copy(vi.end() - j, vi.end(), back_inserter(arr));
            sort(arr.begin(), arr.end(), greater<int>());
            int maxPopCount = k - i - j;
            int count = 0;
            while (arr.size() > 0 && arr.back() < 0 && count < maxPopCount) {
                count++;
                arr.pop_back();
            }
            ll sum = accumulate(arr.begin(), arr.end(), 0);
            ans = max(sum, ans);
            if (sum == 34) {
                cout << "i" << i << "-" << j << "\n";
                for (int &e: arr) {
                    cout << e << " ";
                }
                cout << "\n";
            }
        }
    }
    return ans;
}


int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> vi;
    rep(i, n) {
        ll v;
        cin >> v;
        vi.push_back(v);
    }
    ll ans = solve(n, k, vi);
    cout << ans << "\n";
} 

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

int main()
{
	long a,b,k;
	cin >> a >> b >> k;
	for(int i=a;i <= min(b,a+k-1);i++){
		cout << i << endl;
	}
	for(int i=max(b-k+1,a+k);i <= b;i++){
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b , a%b)	

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

lc = (c*d) // gcd(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+lc_count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<pair<ll, ll>> p(N);
    rep(i, 0, N)
    {
        ll a, b;
        cin >> a >> b;
        p.at(i) = make_pair(b, a);
    }
    sort(all(p));
    ll total = p.at(0).second;
    ll due = p.at(0).first;
    rep(i, 1, N)
    {
        total += p.at(i).second;
        if (p.at(i).first != p.at(i - 1).first)
        {
            due = p.at(i).first;
        }
        if (total > due)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if (total > p.at(N - 1).first)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 6340
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def comb(a, b):
    return fact[a] * pow(fact[a-b], mod-2, mod) * pow(fact[b], mod-2, mod) % mod
n, m = LI()
fact = [1] * (max(n, m) + 1)
for i in range(1, max(n, m)+1):
    fact[i] = i * fact[i-1]
    fact[i] %= mod

ret = 0
for x in range(n+1):
    if x % 2:
        ret -= comb(n, x) * fact[m-x] * pow(fact[m-x-(n-x)], mod-2, mod)
        ret %= mod
    else:
        ret += comb(n, x) * fact[m-x] * pow(fact[m-x-(n-x)], mod-2, mod)
        ret %= mod

ans = fact[m] * pow(fact[m-n], mod-2, mod) * ret
ans %= mod
print(ans)

Measured memory_bytes: 90352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++) cin >> H[i];
  int ans = 1;
  for(int i = 1; i < N; i++){
    bool ok = true;
    for(int j = 0; j < i; j++){
      if(H[i] < H[j]) ok = false;
    }
    ans += ok;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
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 MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    while(true){
        ll H,W;cin>>H>>W;
        if(H+W==0)break;
        rep(i,H){
            rep(j,W){
                if((i+j)%2)cout<<".";
                else cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
n, m = map(int, input().split())
s = [False] * (n + 1)
t = [False] * (n + 1)
for i in range(m):
  a, b = map(int, input().split())
  if a == 1:
    s[b] = True
  if b == n:
    t[a] = True
for i in range(2, n):
  if s[i] and t[i]:
    print('POSSIBLE')
    break
else:
  print('IMPOSSIBLE')


Measured memory_bytes: 6132
a = list(input())
b = list(input())
c = list(input())

s = a.pop(0)
for i in range(400):
    if s == 'a':
        if a == []:
            break
        s = a.pop(0)
    elif s == 'b':
        if b == []:
            break
        s = b.pop(0)
    elif s == 'c':
        if c == []:
            break
        s = c.pop(0)
print(s.upper())

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long N,ans=1; 
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i<N; ++i) {
        cin >> A[i];
        if (A[i]==0) {
            cout << 0;
            return 0;
        }
    }
    for (int i = 0; i<N; ++i){
        if (A[i]>1000000000000000000/ans) {
            cout << -1;
            return 0;
        }
        ans*=A[i];
    }
    cout << ans;
}

Measured memory_bytes: 3980
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		long[] v = new long[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextLong();
		}
		sc.close();

		Arrays.sort(v);
		reverse(v);
		long va = v[a - 1];
		int big = 0;
		int eq = 0;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			if (v[i] > va) {
				big++;
			} else if (v[i] == va) {
				eq++;
			}
			if (i < a) {
				sum += v[i];
			}
		}
		BigDecimal bs = BigDecimal.valueOf(sum);
		BigDecimal ba = BigDecimal.valueOf(a);
		System.out.println(bs.divide(ba, 25, BigDecimal.ROUND_HALF_UP).toPlainString());

		if (big > 0) {
			System.out.println(nCr(eq, a - big));
		} else {
			long ans = 0;
			int end = Math.min(eq, b);
			for (int i = a; i <= end; i++) {
				ans += nCr(eq, i);
			}
			System.out.println(ans);
		}
	}

	static long nCr(int n, int r) {
		long val = 1;
		for (int i = 1; i <= r; i++) {
			val = val * (n - i + 1) / i;
		}
		return val;
	}

	static void reverse(long[] a) {
		for (int i = 0; i < a.length / 2; i++) {
			long tmp = a[i];
			a[i] = a[a.length - 1 - i];
			a[a.length - 1 - i] = tmp;
		}
	}
}


Measured memory_bytes: 21332
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	d := make([]int, n + 1)
	count := 1
	for i := 0; i < n; i++ {
		d[i + 1] = d[i] + arr[i]
		if d[i + 1] <= x {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int k, a[100005];
int main() {
	scanf("%d", &k);
	for (int i = 1; i <= k; i ++) scanf("%d", &a[i]);
	if (a[k] != 2) return printf("-1\n"), 0;
	ll l = 2, r = 2;
	for (int i = k; i >= 1; i --) {
		l = ((l - 1) / a[i] + 1) * a[i];
		if (l > r) {
			return printf("-1\n"), 0;
		}
		r = (r / a[i] + 1) * a[i] - 1;
	}
	printf("%lld %lld\n", l, r);
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int N,R,sum,result;
    scanf("%d%d",&N,&R);
    if(N>=10)
        printf("%d\n",R);
    else{
        sum=100*(10-N);
        result=R+sum;
        printf("%d",result);
    }
    return 0;
}


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

int n,a,b,c,ans=1e9;

void dfs(vector<int>x, int m=0){
    int s=x.size();
    if(s<3)return;
    rep(i,s)rep(j,s)rep(k,s){
        if(i==j||j==k||k==i)continue;
        int cnt=abs(x[i]-a)+abs(x[j]-b)+abs(x[k]-c);
        ans=min(ans,cnt+m*10);
    }
    if(s==3)return;
    for(int i=0; i<s; ++i)for(int j=i+1; j<s; ++j){
        vector<int>nx;
        rep(k,s)if(k!=i&&k!=j)nx.push_back(x[k]);
        nx.push_back(x[i]+x[j]);
        dfs(nx,m+1);
    }
}

int main(){
    cin>>n>>a>>b>>c;
    vector<int>l(n);
    rep(i,n)cin>>l[i];
    dfs(l);
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();
signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t=1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        // solve();
        int n;
        cin>>n;
        int cost[n];
        rep(i,0,n){
            cin>>cost[i];
        }
        int dp[n+1]={0};
        for( int i=2;i<=n;i++){
            int op1= INT_MAX;
            int op2= INT_MAX;
            if(i-1>0){
                op1 = dp[i-1]+abs(cost[i-1]-cost[i-2]);
            }
            if(i-2>0){
                op2 = dp[i-2]+abs(cost[i-1]-cost[i-3]);
            }
            dp[i]= min(op1,op2);
        }
        // for( int i=1;i<=n;i++){
        //     cout<<dp[i]<<" ";
        // }
        // cout<<endl;
        cout<<dp[n];

    }
    // cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}


Measured memory_bytes: 5184
n = $stdin.readline.to_i
d = Array.new(n) { $stdin.readline.chomp.split.map(&:to_i) }

d.sort_by! {|x, y| x + y }
res = (d[0][0] - d[-1][0]).abs + (d[0][1] - d[-1][1]).abs

d.sort_by! {|x, y| x - y }
res = [res, (d[0][0] - d[-1][0]).abs + (d[0][1] - d[-1][1]).abs].max
puts res

Measured memory_bytes: 36160
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	int A, B;
	cin >> A >> B;
	
	if (A % B==0 ) {
		A= -1;
	}
	cout << A<< endl;
}

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


int main() {

    int n;
    scanf("%d", &n);
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        int t;
        scanf("%d", &t);
        if(t != i) cnt++;
    }
    if(cnt <= 2) printf("YES");
    else printf("NO");
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
typedef long long ll;
#define all(v) ((v).begin()), ((v).end())	
#define sz(v) v.size()
#define endl "\n"
constexpr auto EPS = 1e-9;
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
ll gcd(ll n, ll m) {
    if (m == 0)return n;
    return gcd(m, n % m);
}
ll lcm(ll n, ll m)
{
    return (n * m) / gcd(n, m);
}
void GOAT()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);

#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
}
const int m = 2019;
int main()
{
    GOAT();
    string s;
    cin >> s;
    int suf = 0, po = 1;
    vector<int>cnt(m);  
    ll ans = 0;
    cnt[0]++;
    for (int i = sz(s) - 1; i >= 0; i--)
    {
        int dig = s[i] - '0';
        suf = (suf+dig * po) % m;
       po= 10*po% m;
        ans += cnt[suf];
        cnt[suf]++;

    }
    cout << ans << endl;
}


Measured memory_bytes: 3732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if(n <= m)
			System.out.println("unsafe");
		else
			System.out.println("safe");
	}

}


Measured memory_bytes: 35860
#include <stdio.h>
#include "iostream"
#include "deque"
#include "vector"
#include "string"

using namespace std;

int main(){
    int H, W;
    const int INF = 1e9+1;
    vector<int> C(2), D(2);
    deque<int> que_y;
    deque<int> que_x;

    cin >> H >> W;
    cin >> C[0] >> C[1];
    cin >> D[0] >> D[1];

    vector<string> S(H);
    vector<vector<int>> maze_visited(H, vector<int>(W, INF));

    for(int i = 0; i < H; i++){
        cin >> S[i];
    }

    que_y.push_front(C[0]-1);
    que_x.push_front(C[1]-1);
    maze_visited[C[0]-1][C[1]-1] = 0;

    while(!que_y.empty()){
        int y = que_y.front();
        int x = que_x.front();
        que_y.pop_front();
        que_x.pop_front();
        for(int i = -2; i <= 2; ++i){
            for(int j = -2; j <= 2; ++j){
                if(i != 0 || j != 0){
                    int n_x = x + i;
                    int n_y = y + j;
                    int mv_n = maze_visited[n_y][n_x];
                    int mv_c = maze_visited[y][x];
                    if(n_x >= 0 && n_y >= 0 && n_x < W && n_y < H){
                        if(S[n_y][n_x] == '.'){
                            if(abs(i) + abs(j) <= 1){
                                if(mv_n > mv_c){
                                    maze_visited[n_y][n_x] = mv_c;
                                    que_y.push_front(n_y);
                                    que_x.push_front(n_x);
                                }
                            } else {
                                if(mv_n > mv_c + 1){
                                    maze_visited[n_y][n_x] = mv_c + 1;
                                    que_y.push_back(n_y);
                                    que_x.push_back(n_x);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    if(maze_visited[D[0]-1][D[1]-1] == INF){
        cout << -1 << endl;
    } else {
        cout << maze_visited[D[0] - 1][D[1] - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 8636