akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, T;
  cin >> n >> T;
  bool x = false;
  ll ans = MOD;
  rep(i, n){
    ll c, t;
    cin >> c >> t;
    if(t<=T){
      chmin(ans, c);
      x = true;
    }
  } 
  if(x){
    print(ans);
  }
  else{
    print("TLE");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w;
char s[500][500];
ll x[800005],y[800005],z[900005];
ll dp[500][500];

int main(){	
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>s[i];
		for(j=0;j<w;j++){
			if(s[i][j]=='#')ans++;
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	pqps.push(P(0,0));
	bool flag=false;
	while(!pqps.empty() && !flag){
		P p = pqps.top();
		pqps.pop();
		ll cost = p.first;
		ll x = p.second / 100;
		ll y = p.second % 100;
		for(int i=0;i<4;i++){
			ll nx = x + dx[i];
			ll ny = y + dy[i];
			if(nx>=0 && nx<h && ny>=0 && ny<w && dp[nx][ny]>cost+1 && s[nx][ny]!='#'){
				dp[nx][ny] = cost + 1;
				if(nx == h-1 && ny == w-1){
					flag = true;
				}
				pqps.push(P(cost+1,100*nx+ny));
			}
		}
	}
	if(dp[h-1][w-1]==INF){
		p(-1);
	}else{
		p(h*w-ans-dp[h-1][w-1]-1);
	}
	//first = kyori second = 100*x+y
	
	return 0;
}

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

signed main(){
  int A,B,K;
  cin>>A>>B>>K;
  if(K<=A)cout<<A-K<<" "<<B<<endl;
  else if(K<=A+B)cout<<0<<" "<<B-(K-A)<<endl;
  else cout<<0<<" "<<0<<endl;
}

Measured memory_bytes: 256
from collections import Counter

N = input()
A_str = input().split()

if "0" in A_str:
    print(0)
    exit()

c = Counter(sorted(A_str))
res = 1
for i, v in c.items():
    res *= int(i) ** v

    if res > 10 ** 18:
        res = -1
        break

print(res)


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

template<typename T>
struct SegmentTree {
	private:
        using Func = function<T(T, T)>;

        int n;
        vector<T> node;

        T init_v;
        Func func;

    public:

        SegmentTree(vector<T> a, Func _func, T _init_v) {
            int sz = a.size();
            n = 1;
            init_v = _init_v;
            func = _func;
    
            while (n < sz) n <<= 1;
            node.resize(2 * n - 1, init_v);
            for (int i = 0; i < sz; i++) node[i + n - 1] = a[i];
            for (int i = n - 2; i >= 0; i--) node[i] = func(node[i * 2 + 1], node[i * 2 + 2]);
        }

        void update(int pos, T v) {
            int k = pos + n - 1;
            node[k] = v;
            while (k > 0) {
                k = (k - 1) / 2;
                node[k] = func(node[k * 2 + 1], node[k * 2 + 2]);
            }
        }

        T get(int pos) {
            int k = pos + n - 1;
            return node[k];
        }

        T query(int a, int b, int k = 0, int l = 0, int r = -1) {
            if (r < 0) r = n;
            if (r <= a || b <= l) return init_v;
            if (a <= l && r <= b) return node[k];
            T lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return func(lv, rv);
        }

        int size(){
            return n;
        }
};

int func(int a, int b){
    return min(a,b);
}

int main(void){
    int n,q; cin >> n >> q;
    vector<int> a(n, INT_INF);

    SegmentTree<int> st(a, func, INT_INF);
    REP(i,q){
        int c,x,y; cin >> c >> x >> y;
        if(c)  cout << st.query(x,y+1, 0, 0, st.size()) << endl;
        else st.update(x, y);
    }
    return 0;
}


Measured memory_bytes: 4736
#include <stdio.h>
#define N 8
#define NOT_FREE 0
#define FREE 1
int row[N],col[N],dpos[15],dneg[15],A[N][N];
int i,j,n,r,c;

void printBoard(){
  for(i=0;i<N;i++){
      for(j=0;j<N;j++){
      if(A[i][j]&&row[i]!=j)return;
      }
  }
  for(i=0;i<N;i++){
      for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else{printf(".");}
      }
      printf("\n");
  }
}


void putQueen(int i)
{
  int j;
  if(i==N){
      printBoard();
      return;
  }

  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;
      col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
      putQueen(i+1);
      col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
}



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

  for(i=0;i<15;i++){
      dpos[i]=dneg[i]=FREE;
  }

  for(i=0;i<N;i++){
      col[i]=row[i]=FREE;
      for(j=0;j<N;j++){
        A[i][j]=0;
    }
  }



  for(i=0;i<n;i++){
      scanf("%d%d",&r,&c);
      A[r][c]=90;
    }
  putQueen(0);
  return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int DP1[3005][3005], DP2[3005][3005]; // Tまでにたべきる

int main() {
  int N, T;
  cin>>N>>T;
  int A[N], B[N];
  for(int i=0;i<N;++i) cin>>A[i]>>B[i];
  for(int i=0;i<T;++i) {
    if(i>=A[0]) DP1[0][i] = B[0];
  }
  for(int i=1;i<N;++i) {
    for(int j=0;j<T;++j) {
      DP1[i][j] = DP1[i-1][j];
      if(j>=A[i]) DP1[i][j] = max(DP1[i][j], DP1[i-1][j-A[i]]+B[i]);
    }
  }
  for(int i=0;i<T;++i) {
    if(i>=A[N-1]) DP2[N-1][i] = B[N-1];
  }
  for(int i=N-2;i>=0;--i) {
    for(int j=0;j<T;++j) {
      DP2[i][j] = DP2[i+1][j];
      if(j>=A[i]) DP2[i][j] = max(DP2[i][j], DP2[i+1][j-A[i]]+B[i]);
    }
  }
  int ans = 0;
  ans = max(DP2[1][T-1]+B[0], DP1[N-2][T-1]+B[N-1]);
  for(int i=1;i<N-1;++i) {
    for(int j=0;j<T;++j) {
      ans = max(ans, DP1[i-1][j]+DP2[i+1][T-1-j]+B[i]);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 74052
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;


char buf[110][20];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%s", buf[i]);
  }
  bool ok = true;
  REP(i, n-1) {
    int len = strlen(buf[i]);
    if(buf[i][len-1] != buf[i+1][0]) {
      ok = false;
    }
  }
  REP(i, n) {
    REP(j, i) {
      if(strcmp(buf[i], buf[j]) == 0) {
        ok = false;
      }
    }
  }
  puts(ok ? "Yes" : "No");

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define LENGTH 3

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

Measured memory_bytes: 1028
#include <cstdio>
#include <vector>

using namespace std;


vector<pair<int, int> > adj[110000];
long cost[110000];

void go(int pos, long cst){
  cost[pos] = cst;
  for(vector<pair<int, int> >::iterator iter = adj[pos].begin(); iter != adj[pos].end(); ++iter){
    if(cost[(*iter).first] == -1){
      go((*iter).first, cst + (*iter).second);
    }
  }
}


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

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

  for(int i = 0; i < N-1; i++){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    adj[a].push_back(make_pair(b, c));
    adj[b].push_back(make_pair(a,c ));
  }

  int Q, K;
  scanf("%d %d", &Q, &K);

  go(K, 0);

  for(int i = 0; i < Q; i++){
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%ld\n", cost[x] + cost[y]);

  }

  return 0;


}

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


int main(){

    int A, B;
    cin >> A >> B;
    if((max(A,B)-min(A,B))%2==0){
        cout << (max(A,B)-min(A,B))/2+min(A,B) << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}

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

public class Main {
	
	static int n;
	static ArrayList<Integer>[] adjList;
	static int[] counter, value;
	static boolean[] vis;
	
	public static void dfs(int u, int c) {
		vis[u] = true;
		c += counter[u];
		value[u] = c;
		
		for(int v : adjList[u])
			if(!vis[v])
				dfs(v, c);
	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st;
		
		st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		int q = Integer.parseInt(st.nextToken());
		
		adjList = new ArrayList[n];
		for(int i = 0; i < n; i++)
			adjList[i] = new ArrayList<Integer>();
		
		for(int i = 0; i < n - 1; i++) {
			st = new StringTokenizer(br.readLine());
			int u = Integer.parseInt(st.nextToken()) - 1, v = Integer.parseInt(st.nextToken()) - 1;
			adjList[u].add(v);
			adjList[v].add(u);
		}
		
		counter = new int[n];
		for(int i = 0; i < q; i++) {
			st = new StringTokenizer(br.readLine());
			counter[Integer.parseInt(st.nextToken()) - 1] += Integer.parseInt(st.nextToken());
		}
		
		value = new int[n];
		vis = new boolean[n];
		dfs(0, 0);
		
		for(int i = 0; i < n; i++)
			pw.print(value[i] + (i == n - 1 ? "\n" : " "));
		
		pw.flush();
		pw.close();
	}
}


Measured memory_bytes: 125644
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

int a[100'000];
int lowest[100'000];

int main()
{
    int n;

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

    int cols = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        int ub = cols;
        int lb = -1;
        while (lb + 1 < ub)
        {
            int mid = (ub + lb) / 2;

            if (lowest[mid] > a[i])
            {
                ub = mid;
            }
            else
            {
                lb = mid;
            }
        }

        if (ub < cols)
        {
            lowest[ub] = a[i];
        }
        else
        {
            lowest[cols++] = a[i];
        }
    }

    cout << cols << endl;

    return 0;
}

Measured memory_bytes: 1024
#もらうDPで考える
N, K = map(int, input().split())

l = []
r = []

MOD = 998244353

for i in range(K):
    a,b = map(int, input().split())
    l.append(a)
    r.append(b)

dp = [0] * (N+1)
#スタート地点が1なので、dp[1]を1とする
dp[1] = 1

dpsum = [0] * (N+1)
dpsum[1] = 1

for i in range(2, N+1):
    for j in range(K):
        #[l[i], r[i]]
        li = i - r[j]
        ri = i - l[j]
        if ri < 0: continue
        # l1が負になるケースをハンドリング
        li = max(1, li)
        dp[i] += (dpsum[ri] - dpsum[li-1])%MOD #dp[li] ~ dp[ri]の和を足す
    dpsum[i] = (dpsum[i-1] + dp[i])%MOD

print(dp[N]%MOD)

Measured memory_bytes: 76920
a=input()
b=input()
A=len(a)
B=len(b)

if A<B:
    print("LESS")
elif B<A:
    print("GREATER")
else:
    for i in range(A):
        if int(a[i])<int(b[i]):
            print("LESS")
            break
        elif int(b[i])<int(a[i]):
            print("GREATER")
            break
        elif int(a[i])==int(b[i]) and i==A-1:
            print("EQUAL")



Measured memory_bytes: 3064
use std::io::BufRead;
fn main() {
    let stdin = std::io::stdin();
    let mut lines: Vec<Vec<i64>> = stdin
        .lock()
        .lines()
        .map(|l| {
            l.unwrap()
                .split_whitespace()
                .map(|w| w.parse().unwrap())
                .collect()
        })
        .collect();
    let (n, k, mut al, mut fl) = (lines[0][0], lines[0][1], lines.remove(1), lines.remove(1));
    if al.iter().sum::<i64>() <= k {
        println!("0");
        return;
    } else {
        al.sort();
        al.reverse();
        fl.sort();
        let mut list: Vec<_> = al.iter().zip(fl.iter()).collect();
        list.sort();
        list.reverse();
        let mut lp: i64 = 1;
        let mut rp: i64 = 1 << 60;
        let mut mp: i64 = (lp + rp) / 2;
        while (lp != mp) || (mp != rp) {
            let cnt: i64 = list
                .iter()
                .filter(|&&(a, f)| (a * f) > mp)
                .map(|&(a, f)| a - (mp / f))
                .sum();
            // let mut cnt: i64 = 0;
            // for &(a, f) in &list {
            //     if (a * f) > mp {
            //         cnt += a - (mp / f);
            //     } else {
            //         break;
            //     }
            // }
            if k < cnt {
                lp = mp + 1;
            } else {
                rp = mp;
            }
            mp = (lp + rp) / 2;
        }
        println!("{}", mp);
    }
}


Measured memory_bytes: 15072
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N=1e18;
ll pow5(ll s){
    return s*s*s*s*s;
}
void solve(){
    ll x;
    cin>>x;
    ll i,j;
    unordered_set<ll> s;
    vl v;
    for(i=0;i<=1000;i++){
        for(j=0;j<=1000;j++){
            if(pow5(i)-pow5(j)==x){
                cout<<i<<" "<<j<<endl;
                return;
            }
            if(pow5(i)-pow5(-j)==x){
                cout<<i<<" "<<-j<<endl;
                return;
            }
            if(pow5(-i)-pow5(-j)==x){
                cout<<-i<<" "<<-j<<endl;
                return;
            }
            if(pow5(-i)-pow5(j)==x){
                cout<<-i<<" "<<j<<endl;
                return;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
// AOJ 585 Nearest Two Points
// 2017.9.24 bal4u
// 2018.3.17

#include <stdio.h>

#include <stdio.h>
#include <stdlib.h>

#define INF     0x70707070
#define RANGE	10

typedef struct { int x, y; } T;
T tbl[500100];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	if (c == '-') {	c = getchar_unlocked();
		do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int cmp(T *a, T *b)
{
	if (a->x - b->x) return a->x - b->x;
	return a->y - b->y;
}

int main()
{
	int N, i, j, lim;
	int dx, dy, d, t, ans;

	N = in();
	for (i = 0; i < N; i++) tbl[i].x = in(), tbl[i].y = in();
	qsort(tbl, N, sizeof(T), cmp);

	ans = INF; d = 0;
	for (i = 0; i < N; i++) {
		lim = i+RANGE; if (lim > N) lim = N;
		for (j = i+1; j < lim; j++) {
			dx = tbl[i].x-tbl[j].x;
			dy = tbl[i].y-tbl[j].y;
			t = dx*dx + dy*dy;
			if (t < ans) ans = t;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 9208
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int a, b;
	cin >> a >> b;
	a--; b--;

	vector<vector<string>> ans(100);
	for (int i = 0; i < 50; i++) {
		ans[i].assign(100, "#");
	}
	for (int i = 50; i < 100; i++) {
		ans[i].assign(100, ".");
	}

	for (int x = 0, y = 0; a > 0; a--) {
		ans[y][x] = '.';
		x += 2;
		if (x >= 100) {
			x = 0;
			y += 2;
		}
	}

	for (int x = 0, y = 99; b > 0; b--) {
		ans[y][x] = '#';
		x += 2;
		if (x >= 100) {
			x = 0;
			y -= 2;
		}
	}

	cout << "100 100" << endl;

	for (auto s : ans) {
		for (auto c : s) {
			cout << c;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
uses math;
var
    n, limw, i, j : longint;
    w, v : array[1..105] of longint;
    dp : array[0..105, 0..100005] of int64;

begin
    readln(n, limw);
    for i := 1 to n do readln(w[i], v[i]);
    fillchar(dp, sizeof(dp), 0);
    for i := 1 to n do
    for j := 0 to limw do
    begin
        dp[i, j] := dp[i - 1, j]; 
        if (j >= w[i]) then dp[i, j] := max(dp[i, j], dp[i - 1, j - w[i]] + v[i])
    end;
    writeln(dp[n, limw]);
end.

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

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 1e6+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int N,K;
int cnt[MAXN];

void work(){
    scanf("%d%d",&N,&K);
    for(int i=1;i<=N;i++) cnt[i%K]++;
    cnt[K]=cnt[0];
    LL ans=(LL)cnt[0]*cnt[0]*cnt[0];
    if(K%2==0) ans+=(LL)cnt[K/2]*cnt[K/2]*cnt[K/2];
    printf("%lld\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}





Measured memory_bytes: 640
n,l=map(int,input().split())
pi=0
a=[]
abs_a=[]
for i in range(1,n+1):
    pi+=l+i-1
    a.append(l+i-1)

for i in range(n):
    abs_a.append(abs(a[i]))    

if max(a)<0:
    p=pi+min(abs_a)
else:
    p=pi-min(abs_a)
    
print(p)

Measured memory_bytes: 3060
import numpy as np
N = input()
bars = list(map(int, input().split(" ")))

length = len(bars)

def check_triangle(a, b, c):
    if a == b or b == c or c == a:
        return 0
    if ((a + b) > c) and ((b + c) > a) and ((c + a) > b):
        return 1
    else:
        return 0


count = 0
for i, li in enumerate(bars):
    for k in range(i+1, length):
        res = np.sum([check_triangle(bars[i], bars[k], bars[j]) for j in range(k+1, length)])
        count += int(res)
print(count)

Measured memory_bytes: 27240
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n, m = map(int, input().split())
    x = sorted(list(map(int, input().split())))
    if n >= m:
        print(0)
        exit()
    minimum = x[0]
    maximum = x[-1]
    if n == 1:
        print(maximum-minimum)
        exit()
    arr = []
    for i in range(len(x)-1):
        arr.append(abs(x[i+1]-x[i]))

    arr.sort()

    print(maximum-minimum-sum(arr[-(n-1):]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13308
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
#define ref goto refrain
int main(){
	int m,tp=0,hp=0;
	cin>>m;
	string taro,hanako;
	for(int i=0;i<m;i++){
		cin>>taro;
		cin>>hanako;
		if(taro<hanako){
			hp+=3;
		}
		else if(taro>hanako){
			tp+=3;
		}
		else{
			hp++;
			tp++;
		}
	}
	cout<<tp<<' '<<hp<<endl;
	return 0;
}
		
	

Measured memory_bytes: 1208
while True:
    h,w = map(int,raw_input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i % 2 == 0:
            a = '#.'
        else :
            a = '.#'
        if w % 2 == 0:
            print a*(w/2)
        else:
            print a*(w/2)+a[0]
    print ''

Measured memory_bytes: 6384
#include<iostream>

using namespace std;

int main()
{
    int n;

    cin>>n;
   bool flag=false;

    for(int i=1;i<=9;i++){

        for(int j=i;j<=9;j++){

          if(n==(i*j))flag=true;
            //cout<<i*j<<" ";
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;

}


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

#define MAX_LIMIT 100000

int main(){
    int N;
    cin >> N;
    vector<int> L(N);

    vector<int> X(MAX_LIMIT+10);


    for(int i = 0;i < N;i++)
        cin >> L.at(i);
    
    int res = 0;

    sort(L.begin(),L.end());

    for(int i = 0;i < N;++i){
        if(L.at(i) != 0){
            X[L.at(i)-1]++;
            X[L.at(i)]++;
            X[L.at(i)+1]++;
        }
        else{
            X[L.at(i)]++;
            X[L.at(i)+1]++;
        }
    
    }

    int mx = -1;

    for(int i = 0;i <= MAX_LIMIT;i++){
        if(mx < X[i])
            mx = X[i];
    }

    cout << mx << endl;



}


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

int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double ans;
  if(x<a*a*b/2){
    ans=90-(180/M_PI)*atan(2*x/(a*b*b));
  }else{
    ans=(180/M_PI)*atan(2*(a*a*b-x)/(a*a*a));
  }
  cout << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define SIZE 200000

int PAR[SIZE],RANK[SIZE];
void init_uf(int n){for(int i=0;i<n;i++){PAR[i]=i;RANK[i]=0;}}//initialize
int root(int i){return PAR[i]==i?i:(PAR[i]=root(PAR[i]));}//search group
int same(int x,int y){return root(x)==root(y);}//judge same group
void unite(int x,int y){//add edge
  x=root(x);y=root(y);
  if(x==y)return;
  if(RANK[x]<RANK[y])PAR[x]=y;
  else{PAR[y]=x;if(RANK[x]==RANK[y])RANK[x]++;}
}
void quicksort(long int a[],long int v[],int s,int t){
  if(s<t){
    int i=s,j=t,p=v[a[(s+t)/2]];
    while(1){
      while(v[a[i]]<p)i++;
      while(p<v[a[j]])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,v,s,i-1);quicksort(a,v,j+1,t);
  }
}
int main(){
  long int a[200000],n,i,t=0,x[100000],y[100000],c[200000],l[200000][2];
  scanf("%ld",&n);
  for(i=0;i<n;i++)scanf("%ld%ld",&x[i],&y[i]);
  for(i=0;i<n;i++)a[i]=i;
  quicksort(a,x,0,n-1);
  for(i=0;i<n-1;i++){c[i]=x[a[i+1]]-x[a[i]];l[i][0]=a[i];l[i][1]=a[i+1];}
  quicksort(a,y,0,n-1);
  for(i=0;i<n-1;i++){c[n+i-1]=y[a[i+1]]-y[a[i]];l[n+i-1][0]=a[i];l[n+i-1][1]=a[i+1];}
  for(i=0;i<n*2-2;i++)a[i]=i;
  quicksort(a,c,0,n*2-3);
  init_uf(n*2);
  for(i=0;i<n*2-2;i++)if(!same(l[a[i]][0],l[a[i]][1])){t+=c[a[i]];unite(l[a[i]][0],l[a[i]][1]);}
  printf("%ld",t);
}


Measured memory_bytes: 9472
#include <iostream>

using namespace std;

int sum_of_disits(int n) {
  int r = 0;
  while (n > 0) {
    r += n % 10;
    n /= 10;
  }
  return r;
}

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

  cin >> N >> A >> B;

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = sum_of_disits(i);
    if (sum >= A && sum <= B) {
      ans += i;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

breakFlag = False
for i in range(1,m-1):
    if a[i]%2==1:
        if a[0]%2==1:
            if a[len(a)-1]%2==1:
                print("Impossible")
                breakFlag = True
                break
            else:
                a[i],a[len(a)-1] = a[len(a)-1],a[i]
        else:
            a[i],a[0] = a[0],a[i]

if breakFlag==False:
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])
    if m==1:
        if a[0]>1:
            a[0]-=1
            a.append(1)
            print(m+1)
        else:
            print(m)
    else:
        if a[len(a)-1]==1:
            print(m-1)
            a.pop()
            a[0]+=1
        else:
            print(m)
            a[0]+=1
            a[len(a)-1] -= 1
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    cout << min(B/A,C) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nk = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);
        if (n % k == 0) {
            System.out.println(0);
        } else {
            System.out.println(1);
        }
    }
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define in2(x, y) int x,y;cin>>x>>y
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)

#define lim5 100002
#define lim9 1000000002

int main(){
	in(n);
	map<int, int> a;
	rep(i, n){
		int x;
		cin >> x;
		a[x] = i + 1;
	}
	rep(i, n) cout << a[i + 1] << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 5504
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  bool x_flag = false;
  bool y_flag = false;

  if (W / 2 == x && W % 2 == 0) {
    x_flag = true;
  }
  if (H / 2 == y && H % 2 == 0) {
    y_flag = true;
  }
  double ans = H * W / 2.0;
  printf("%0.6lf %d\n", ans, (int)(x_flag && y_flag));

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define mkp make_pair
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}

int main()
{
	ll a,b;
	char type;
	scanf("%lld %c%lld",&a,&type,&b);
	if(type=='+') printf("%lld\n",a+b);
	else printf("%lld\n",a-b);
	return 0;
}


Measured memory_bytes: 256
/* CM one day */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
const int inf = (int)1e17;
const int N = (int)1e5+5;
int32_t main(){


	FASTIO;
	int n;
	cin >> n;
	int ans = 0;
	REP(i,1,n+1){
		if(i%3 != 0 && i%5!=0){
			ans += i;
		}
	}
	cout << ans << endl;
    return 0;

}

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

int a[105];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++ ) scanf("%d",&a[i]);
    int cnt=0;
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    {
        int f=a[i],s=0;
        for(int j=i;j<=n;j++)
        { 
            bool flag=0;
            int sum=f;
            int tot=0;
            if(a[j]!=f)
            {
                s=a[j];
                flag=1;
                sum+=s;
                tot=j;
            }
            if(flag)
            {
                for(;tot<=n;tot++)
                {
                    if(a[tot]!=s&&a[tot]<sum)
                        cnt++;
                }
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,cnt=0,ans=0;
    cin >> n;
    long a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    for(long i=0;i<n-1;i++){
        cnt += a[i];
        if(2*cnt<a[i+1]) ans = max(i+1,ans);
    }
    cout << n-ans << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n, k;
    cin >> n >> k;
    VI a(n + 2);
    for (i = 1; i <= n; i++) cin >> a[i];
    bool ok = 0;
    for (i = 1; i <= n; i++) {
        if (a[i] > 0) ok = 1;
    }
    if (k >= 2000) {
        for (i = 0; i < n; i++) {
            if (i == 0)
                cout << n;
            else
                cout << " " << n;
        }
        cout << endl;
        return 0;
    }
    for (j = 0; j < k; j++) {
        VI b(n + 2, 0);
        for (i = 1; i <= n; i++) {
            b[max(0ll, i - a[i])]++;
            b[min(n + 1, i + a[i] + 1)]--;
        }
        for (i = 1; i <= n + 1; i++) {
            b[i] += b[i - 1];
        }
        swap(a, b);
    }
    for (i = 1; i <= n; i++) {
        if (i == 1)
            cout << a[i];
        else
            cout << " " << a[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll LNF = __LONG_LONG_MAX__;

int main(){
    int N; cin >> N;
    bool f=false;
    int cnt=0;
    for(int i=0;i<N;i++){
        int d1,d2; cin >> d1 >> d2;
        if(d1==d2){
            cnt++;
        }else{
            cnt=0;
        }
        if(cnt>=3) f=true;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String []s=br.readLine().split(" ");
		String S = s[0];
		String T = s[1];
		
		s=br.readLine().split(" ");
		int A = Integer.parseInt(s[0]);
		int B = Integer.parseInt(s[1]);
		
		String U = br.readLine();
		
		if(U.equals(S))
			out.println((A-1)+" "+B);
		else
			out.println(A+" "+(B-1));
		
	}
}




Measured memory_bytes: 22484
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
using namespace std;

string S;
int first_half;
int second_half;

int main() {
	cin >> S;
	first_half = (S[0] - '0') * 10 + (S[1] - '0');
	second_half = (S[2] - '0') * 10 + (S[3] - '0');
	if (((first_half >= 1) & (first_half <= 12)) & ((second_half == 0) or (second_half > 12))) cout << "MMYY" << endl;
	else if (((first_half == 0) or (first_half > 12)) & ((second_half >= 1) & (second_half <= 12))) cout << "YYMM" << endl;
	else if (((first_half >= 1) & (first_half <= 12)) & ((second_half >= 1) & (second_half <= 12))) cout << "AMBIGUOUS" << endl;
	else  cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

struct Data{
    int a, b, c;
};

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

    int dig[205];
    rep(i,d) cin >> dig[i];

    Data cl[205];
    rep(i,n) cin >> cl[i].a >> cl[i].b >> cl[i].c;

    int dp[205][205] = {{0}}; //テヲツ慊?・ツセツ古」ツ?ォテァツ敖?」ツ?淌ヲツ慊催」ツ??ヲツ猟・
    memset(dp, -1, sizeof(dp));
    rep(i,n){
        if(cl[i].a <= dig[0] && dig[0] <= cl[i].b){
            dp[i][0] = 0;
        }
    }

    range(i,1,d){
        rep(j,n){
            if(cl[j].a <= dig[i] && dig[i] <= cl[j].b){
                rep(k,n){
                    if(dp[k][i - 1] == -1) continue;
                    dp[j][i] = max(dp[j][i], dp[k][i - 1] + abs(cl[k].c - cl[j].c));
                }
            }
        }
    }

    int maxi = 0;
    rep(i,n){
        maxi = max(maxi, dp[i][d - 1]);
    }
    cout << maxi << endl;
}

Measured memory_bytes: 3252
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
ll fac[1000005],finv[1000005],inv[1000005];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000005; 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;
    }
}
ll 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() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll x,y,n,m;
  cin >> x >> y;
  if((x+y)%3!=0) {
    cout << 0 << endl;
    return 0;
  }
  n=(2*y-x)/3,m=(2*x-y)/3;
  COMinit();
  cout << COM(n+m,n) << endl;
}



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

using namespace std;

#define ll long long
#define PI 3.14159265358979323846264338327950L

string s;

void solve(){
    cin >> s;


    if(s == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

Measured memory_bytes: 3636
a,b=map(int,input().split())
c=input()
for i in range(len(c)):
  if b!=i+1:
  	print(c[i],end="")
  else:
    if c[i]=="A":
      print("a",end="")
    elif c[i]=="B":
      print("b",end="")
    else:
      print("c",end="")
print("")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, h;
    cin >> n >> h;
    vector<pii> v;
    int amax = 0;
    REP(i,n) {
        int a, b;
        cin >> a >> b;
        amax = max(amax,a);
        v.push_back(make_pair(a,b));
    }
    ll bsum = 0;
    vector<int> vb;
    REP(i,n) {
        if (amax < v[i].second) {
            bsum += v[i].second;
            vb.push_back(v[i].second);
        }
    }
    sort(RALL(vb));

    int ans = 0;
    ll nh = h;
    if(bsum >= nh) {
        int i = 0;
        while(nh > 0) {
            nh -= vb[i];
            ans++;
            i++;
        }
    } else {
        nh -= bsum;
        ans += vb.size();
        if (nh % amax == 0) ans += nh / amax;
        else ans += nh / amax + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1908
K=int(input())
A=list(map(int,input().split()))

n_min=2
n_max=2
for i in range(K-1,-1,-1):
    if (n_max//A[i])*A[i] < n_min or (n_min//A[i]+(1 if n_min%A[i]!=0 else 0))*A[i] > n_max:
        print(-1)
        exit()
    n_min=(n_min//A[i]+(1 if n_min%A[i]!=0 else 0))*A[i]
    n_max=(n_max//A[i])*A[i]+A[i]-1

print(n_min,n_max)

Measured memory_bytes: 63984
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll _pow(ll a, ll n) {
	if(n==0) return 1;
	else {
		ll res = 1;
		ll buf = a;
		while(n>0) {
			if(n%2==1) {
				res *= buf;
				res %= MOD;
			}
			buf *= buf;
			buf %= MOD;
			n/=2;
		}
		return res;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<vector<ll>> pre(401, vector<ll>(401, 0));
	REP(i, 401) REP(j, 401) pre[i][j] = _pow(i, j);
 	int n, c;
	cin >> n >> c;
	vector<int> a(n), b(n);
	REP(i, n) cin >> a[i];
	REP(i, n) cin >> b[i];
	vector<vector<ll>> dp(n + 1, vector<ll>(c + 1, 0));
	dp[n][0] = 1;
	for(int i = n - 1; i >= 0; i--) {
		vector<ll> v(c + 1, 0);
		REP(j, c + 1) {
			for(ll k = a[i]; k <= b[i]; k++) {
				v[j] += pre[k][j];
				v[j] %= MOD;
			}
		}
		for(int j = 0; j <= c; j++) {
			for(int k = 0; k <= j; k++) {
				dp[i][j] += v[k] * dp[i + 1][j - k];
				dp[i][j] %= MOD;
			}
		}
	}
	// REP(i, n + 1) REP(j, c + 1) cout << i << " " << j << " " << dp[i][j] << endl;
	cout << dp[0][c] << endl;
	return 0;
}
/* --------------------------------------- */


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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main(){
    int h,v;
    cin>>h>>v;
    char grid[h][v];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<v;j++)
        {
            cin>>grid[i][j];
        }
    }
    int dp[h][v];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<v;j++)
        {
            dp[i][j]=0;
        }
    }
    for(int i=0;i<h;i++)
    {
        if(grid[i][0]!='#')
        dp[i][0]=1;
        else
            break;
    }
    for(int j=0;j<v;j++)
    {
        if(grid[0][j]!='#')
            dp[0][j]=1;
        else
            break;
    }
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<v;j++)
        {
            if(grid[i][j]!='#')
                dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[h-1][v-1];

}

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

int main(){
	
	//fastio
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n;
	cin>>n;
	cout<<((n*(n-1))/2)<<endl;

	return 0;
}

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

int n;
double x;

int main(){
  cin >> n;
  double tmp = 0.0;
  for(int i=1;i<=n;i++){
    cin >> x;
    tmp += 1.0/x;
  }
  cout << 1.0/tmp << endl;
  return 0;
}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<vector<int>> v(4, vector<int>(14, 0));
  //key=>0=S,1=H,2=C,3=D value=>存在すれば1
  v.at(0).at(0) = 1;//数字を合わせるための調整
  v.at(1).at(0) = 1;
  v.at(2).at(0) = 1;
  v.at(3).at(0) = 1;
  for(int i = 0; i < n; i++) {
    char mark = ' ';
    int num = 0;
    scanf(" %c %d", &mark, &num);
    if(mark == 'S') v.at(0).at(num) = 1;
    else if(mark == 'H') v.at(1).at(num) = 1;
    else if(mark == 'C') v.at(2).at(num) = 1;
    else v.at(3).at(num) = 1;//mark == 'D'
  }
  for(int i = 0; i < 4; i++) {
    char mark = (i == 0)? 'S'
      : (i == 1)? 'H'
        : (i == 2)? 'C'
          : 'D';
    for(int j = 0; j < 14; j++) {
      if(v.at(i).at(j) == 0) printf("%c %d\n", mark, j);
    }
  }
}



Measured memory_bytes: 3220
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d",&a,&b)

	add := a+b
	sub := a-b
	mul := a*b

	ans := add
	if add < sub {
		if sub < mul {
			ans = mul
		} else {
			ans = sub
		}}
	if ans < mul {
		ans = mul
	}
	
	fmt.Println(ans)
}
			
		

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<string> a(n);
    REP(i, n) {
        cin >> a[i];
    }

    int t = 0;
    REP(k, n) {
        bool ok = true;
        REP(i, n) {
            FOR(j, i, n) {
                if (a[i][j] != a[j][i]) {
                    ok = false;
                    break;
                }
            }
            if (!ok) {
                break;
            }
        }
        if (ok) {
            t++;
        }
        vector<string> b;
        REP1(i, n - 1) {
            b.push_back(a[i]);
        }
        b.push_back(a[0]);
        b.swap(a);
    }

    cout << t * n << endl;
}


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

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main() {
  int L;
  cin >> L;

  int sz = 0;
  while((1 << (sz + 1)) <= L) sz++;


  Edges< int > edges;
  int used = 0;
  for(int i = sz - 1; i >= 0; i--) {
    edges.emplace_back(used, used + 1, 1 << i);
    edges.emplace_back(used, used + 1, 0);
    ++used;
  }
  int add = 1 << sz;

  used = 0;
  for(int i = sz - 1; i >= 0; i--) {
    if(L - add >= (1 << i)) {
      edges.emplace_back(0, used + 1, add);
      add += 1 << i;
    }
    ++used;
  }

  cout << used + 1 << " " << edges.size() << endl;
  for(auto &p : edges) cout << p.src + 1 << " " << p.to + 1 << " " << p.cost << endl;

}





Measured memory_bytes: 256