akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long int a[3005];
long long int ans[3005][3005][2];
long long int game(int i, int j, int player){
    if(i>j)
        return 0;
    if(ans[i][j][player-1]!=-1)
        return ans[i][j][player-1];
    if(player==1)
        return ans[i][j][player-1] = max(game(i+1,j,2)+a[i],game(i,j-1,2)+a[j]);
    return ans[i][j][player-1] = min(game(i+1,j,1)-a[i],game(i,j-1,1)-a[j]);
}
int main(){
    int n;
    cin >> n;
    memset(ans, -1, sizeof(ans));
    for(int i=1; i<=n; i++)
        cin >> a[i];
    cout << game(1,n,1);
}

Measured memory_bytes: 144956
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

int main(){
    int a;
    string s;

    cin >> a >> s;

    if(a < 3200){
        cout << "red" << endl;
    }else{
        cout << s <<endl;
    }
    
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ld L; cin >>L;
  ld l = L/3;
  ld r = l*l*l;
  printf("%.8Lf",r);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

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

  static final long MOD = (long) (1e9 + 7);
  static final long INF = Long.MAX_VALUE / 2;

  static final int e5 = (int) 1e5;

  public static class Solver {

    int N;
    int[][] A;
    ArrayDeque<Game> queue;
    ArrayDeque<Game> nextQueue;
    int[] count;
    boolean[][] done;

    public Solver() {

      N = sc.nextInt();

      A = new int[N][N-1];

      for (int i=0; i<N; i++) {
        for (int j=0; j<N-1; j++) {
          A[i][j] = sc.nextInt()-1;
        }
      }

      queue = new ArrayDeque<Game>();
      nextQueue = new ArrayDeque<Game>();

      count = new int[N];

      for (int i=0; i<N; i++) {
        check(i);
      }

      done = new boolean[N][N];

      long ans = 0;
      while (!queue.isEmpty() || !nextQueue.isEmpty()) {

        if (queue.isEmpty()) {
          ans++;
          queue = nextQueue;
          nextQueue = new ArrayDeque<Game>();
        }

        Game game = queue.removeFirst();

        if (done[game.a][game.b] || done[game.b][game.a]) {
          continue;
        }

        done[game.a][game.b] = true;
        count[game.a]++;
        count[game.b]++;

        check(game.a);
        check(game.b);

      }

      boolean ok = true;
      for (int i=0; i<N; i++) {
        if (count[i] != N-1) {
          ok = false;
          break;
        }
      }

      System.out.println(ok ? ans : -1);

    }

    void check(int i) {
      if (count[i] < N-1) {
        int opponent = A[i][count[i]];
        if (count[opponent] < N-1) {
          if (A[opponent][count[opponent]] == i) {
            nextQueue.add(new Game(i, opponent));
          }
        }
      }
    }

    class Game {
      int a, b;
      Game(int A, int B) {
        a = A;
        b = B;
      }
    }
  }

  public static void main(String[] args) {
    new Solver();
  }
}


Measured memory_bytes: 283032
x,k,d=map(int,input().split())
x=abs(x)

if x-k*d>=0:
    print(x-k*d)

else:
    t=x//d
    r=x-t*d
    l=x-(t+1)*d
    if (k-t)%2==1:
        print(abs(l))
    else:
        print(abs(r))

Measured memory_bytes: 9104
# encoding:utf-8

def main():
	s = list(input())
	t = list(input())
	print(checker(s, t))

def checker(s, t):
	for i in range(len(s)):
		if i >= len(t) - 1:
			if checker2(s, t, len(s) - i - 1):
				for i2 in range(len(t)):
					s[len(s) - i  - 1 + i2] = t[i2]
				for i2 in range(len(s)):
					if s[i2] == "?":
						s[i2] = "a"
				return "".join(s)

	return "UNRESTORABLE"


def checker2(s, t, i):
	for i2 in range(len(t)):
		#print(i, i2)
		#print(s[i + i2], t[i2])
		if s[i + i2] == "?":
			continue
		elif s[i + i2] == t[i2]:
			continue
		else:
			return False

	return True



if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

long long prime[100010];
long long isPrime[100011];

long long sieve(long long n){
  long long p = 0;
  for(long long i = 0; i <= n; i++){
    isPrime[i] = 1LL;
  }
  isPrime[0] = 0;
  isPrime[1] = 0;
  for(long long i = 2LL; i <= n; i++){
    if(isPrime[i] == 1LL){
      prime[p] = i;
      p++;
      for(long long j = 2LL * i; j <= n; j += i){
        isPrime[j] = 0;
      }
    }
  }
  return p;
}

ll d[100010];

int main() {
	sieve(100010);
	clr(d,0);
	rep(i,1,100010){
		if(i%2==0)continue;
		if(isPrime[i]==1&&isPrime[(i+1)/2]==1){
			d[i] = 1;
		}
	}
	rep(i,1,100010){
		d[i]+=d[i-1];
	}
	ll q;
	cin>>q;
	rep(i,0,q){
		ll a,b;
		cin>>a>>b;
		cout << d[b]-d[a-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int r = 0;
		for(char c : S.toCharArray()){
			int v = c - '0';
			r = (r + v) % 9;
		}
		if(r % 9 == 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");			
		}
	}
}


Measured memory_bytes: 40476
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
k = []
for i in range(N):
    t_i = T - H[i] * 0.006
    k.append(abs(t_i-A))
ans = k.index(min(k)) + 1
print(ans)

Measured memory_bytes: 9180
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from bisect import bisect, bisect_left
from itertools import accumulate
def main():
    data = list(map(int, read().split()))
    n = data[0]
    a = data[1:n + 1]
    b = data[n + 1: n * 2 + 1]
    c = data[n * 2 + 1:]
    a.sort()
    b.sort()
    c.sort()
    b2 = [bisect_left(a, be) for be in b]
    b2a = list(accumulate(b2))
    b2a = [0] + b2a
    ans = sum([b2a[bisect_left(b, ce)] for ce in c])
    print(ans)

if __name__ == '__main__':
    main()

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

final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String input = inputReader.readLine();
            if (input == null || input.equals("0")) {
                break;
            }
            int inputCount = Integer.parseInt(input);
            String[] matrixInputList = new String[inputCount];
            for (int i = 0; i < inputCount; i++) {
                matrixInputList[i] = inputReader.readLine();
            }
            int[][] matrix = new int[inputCount + 1][inputCount + 1];
            for (int i = 0; i < matrixInputList.length; i++) {
                String[] temp = matrixInputList[i].split(" ");
                for (int j = 0; j < temp.length; j++) {
                    matrix[i][j] = Integer.parseInt(temp[j]);
                }
            }
            for (int i = 0; i < matrix.length - 1; i++) {
                for (int j = 0; j < matrix[i].length - 1; j++) {
                    matrix[inputCount][inputCount] += matrix[i][j];
                    matrix[i][inputCount] += matrix[i][j];
                    matrix[inputCount][j] += matrix[i][j];
                }
            }
            for (int i = 0; i < matrix.length; i++) {
                for (int j = 0; j < matrix[i].length; j++) {
                    System.out.printf("%5d", matrix[i][j]);
                }
                System.out.println();
            }
        }
    }
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	vector<pair<int,int>> a( n );
	for( int i = 0; i < n; ++i ) {
		pair<int, int> xy;
		cin >> xy.first >> xy.second;
		a[i] = xy;
	}

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

	for( int i = 0; i < n; ++i ) {
		cout << a[i].first << ' ' << a[i].second << '\n';
	}

	return 0;
}



Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i, ai in reversed(list(enumerate(a, 1))):
    s = sum(ans[j - 1] for j in range(i + i, n + 1, i))
    ans[i - 1] = (s + a[i - 1]) % 2
ans = list(map(lambda x: x[0], filter(lambda x: x[1] == 1, enumerate(ans, 1))))
print(len(ans))
print(*ans)

Measured memory_bytes: 27200
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a;
  cin>>a;
  double b;
  cin>>b;
  long long c = (long long)(b*100.00 + 0.5);
  long long ans = (a*c)/100;
  cout<<ans<<endl;
  return 0;

}


Measured memory_bytes: 3712
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.06.22 20:57:36
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (ll i = 0; i < x; i++)
#define rep1(i, x) for (ll i = 1; i <= x; i++)
#define rrep(i, x) for (ll i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (ll i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */
ll n;
ll a1, b1;
vector<P> vec;

int main() {
    scanf("%lld", &n);
    rep(i, n) {
        scanf("%lld%lld", &a1, &b1);
        vec.pb(P(a1, b1));
    }

    sort(vec.begin(), vec.end(), [](const P a, const P b) {
        if (a.sc != b.sc)
            return a.sc < b.sc;
        else
            return a.fr < b.fr;
    });

    ll time = 0;
    rep(i, n) {
        ll a = vec[i].fr;
        ll b = vec[i].sc;
        time += a;
        if (time > b) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
const int maxn = 200009;
const int inf = 1e9;
int v1[maxn << 2], v2[maxn << 2], lz1[maxn << 2], lz2[maxn << 2];
//lz1覆盖 lz2+v v1=v2-下标
void build(int rt, int l, int r) {
  lz1[rt] = -inf;
  if (l == r) {
    v1[rt] = -l;
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  v1[rt] = min(v1[rt << 1], v1[rt << 1 | 1]);
}
void pushdownlz1(int rt, int l, int mid) {
  if (lz1[rt] != -inf) {
    lz1[rt << 1] = lz1[rt];
    lz1[rt << 1 | 1] = lz1[rt];
    lz2[rt << 1] = lz2[rt << 1 | 1] = 0;
    v1[rt << 1] = lz1[rt];
    v1[rt << 1 | 1] = lz1[rt];
    v2[rt << 1] = l + lz1[rt];
    v2[rt << 1 | 1] = mid + 1 + lz1[rt];
    lz1[rt] = -inf;
  }
}
void pushdownlz2(int rt) {
  if (lz2[rt]) {
    v1[rt << 1] += lz2[rt];
    v1[rt << 1 | 1] += lz2[rt];
    v2[rt << 1 | 1] += lz2[rt];
    v2[rt << 1] += lz2[rt];
    if (lz1[rt << 1] == -inf)
      lz2[rt << 1] += lz2[rt];
    else
      lz1[rt << 1] += lz2[rt];
    if (lz1[rt << 1 | 1] == -inf)
      lz2[rt << 1 | 1] += lz2[rt];
    else
      lz1[rt << 1 | 1] += lz2[rt];
    lz2[rt] = 0;
  }
}
void upd1(int rt, int l, int r, int ll, int rr, int v, int op) {
  if (ll > rr) return;
  if (ll <= l && rr >= r) {
    if (op == 1) {
      lz2[rt] = 0;
      lz1[rt] = v, v1[rt] = v, v2[rt] = v + l;
    } else {
      if (lz1[rt] == -inf)
        lz2[rt] += v, v1[rt] += v, v2[rt] += v;
      else
        lz1[rt] += v, v1[rt] += v, v2[rt] += v;
    }
    return;
  }
  int mid = (l + r) >> 1;
  if (lz1[rt] != -inf && lz2[rt]) {
    assert(0);
  }
  pushdownlz2(rt);
  pushdownlz1(rt, l, mid);

  if (ll <= mid) upd1(rt << 1, l, mid, ll, rr, v, op);
  if (rr > mid) upd1(rt << 1 | 1, mid + 1, r, ll, rr, v, op);
  v1[rt] = min(v1[rt << 1], v1[rt << 1 | 1]);
  v2[rt] = min(v2[rt << 1], v2[rt << 1 | 1]);
}
int query1(int rt, int l, int r, int ll, int rr) {
  if (ll > rr) return inf;
  if (ll <= l && rr >= r) return v1[rt];
  int mid = (l + r) >> 1, res = inf;
  if (lz1[rt] != -inf && lz2[rt]) {
    assert(0);
  }
  pushdownlz2(rt);
  pushdownlz1(rt, l, mid);
  if (ll <= mid) res = min(res, query1(rt << 1, l, mid, ll, rr));
  if (rr > mid) res = min(res, query1(rt << 1 | 1, mid + 1, r, ll, rr));
  return res;
}
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int h, w;
  cin >> h >> w;
  build(1, 1, w);
  for (int i = 1; i <= h; ++i) {
    int l, r;
    cin >> l >> r;
    int res = query1(1, 1, w, 1, l - 1);
    if (res >= inf) {
      upd1(1, 1, w, l, r, inf, 1);
    } else {
      upd1(1, 1, w, l, r, res + 1, 1);
    }
    upd1(1, 1, w, 1, l - 1, 1, 2);
    upd1(1, 1, w, r + 1, w, 1, 2);
    cout << (v2[1] >= inf ? -1 : v2[1]) << '\n';
  }

  return 0;
}
//2020.08.31 01:00:33


Measured memory_bytes: 11804
import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val a = readLine().split(" ").map(_.toInt)
  val maxAbsIndex = a.indexOf(a maxBy math.abs)

  println(2 * n - 1)
  for (i <- 1 to a.length) println(s"${maxAbsIndex+1} $i")

  if (a(maxAbsIndex) < 0)
    for (i <- n to 2 by -1) println(s"$i ${i - 1}")
  else
    for (i <- 1 until a.length) println(s"$i ${i + 1}")
}


Measured memory_bytes: 25664
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, A[200000]; cin >> N;
  int mx = 0;
  REP(i, N){
    cin >> A[i];
    if(A[i] > mx){
      mx = A[i];
    }
  }
  int cnt = 0;
  REP(i, N){
    if(A[i] == mx) cnt++;
  }
  int mmx = 0;
  REP(i, N){
    if(A[i]!=mx) mmx = max(mmx, A[i]);
  }
  REP(i, N){
    if(A[i] == mx and cnt>1){
      cout << A[i] << endl;
    } else if(A[i]==mx and cnt==1){
      cout << mmx << endl;
    } else {
      cout << mx << endl;
    }
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int Q;
    cin >> Q;
    int count=0;
    string front="";
    while (Q--)
    {
        int type;
        cin >> type;
        if (type==1){
            count++;
        }
        else if (type==2) {
            int f; char c;
            cin >> f >> c;
            if ((count+f)%2) {
                front+=c;
            }
            else s+=c;
        }
    }
    reverse(front.begin(), front.end());
    if (count%2) {reverse(s.begin(), s.end()); reverse(front.begin(), front.end()); cout << s << front << endl;}
    else cout << front << s << endl;
    return 0;
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,m,n,p,q,r;
    cin>>a>>b>>c;

    m=a+b;
    n=b+c;
    p=a+c;
    q=min(m,n);
    r=min(p,q);

    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<int,int> m;
    for(int i=1;i<=102;i++)
    {
        for(int j=1;j<=102;j++)
        {
            for(int k=1;k<=102;k++)
            {
                int x=(i+j)*(i+j);
                int y=(i+k)*(i+k);
                int z=(k+j)*(k+j);
                int p=x+y+z;
                if(p%2==0)
                m[p/2]++;
            
            }
        }
    }
    for(int i=1;i<=n;i++)
    cout<<m[i]<<endl;
}

Measured memory_bytes: 5516
#include<stdio.h>
#include<math.h>
#define ll long long
int main()
{
    ll a,b,c,d,ans;
    while(~scanf("%lld%lld",&a,&b));
    {
        ll t,r=1;
        ll j;
        c=a;d=b;
        if(a<b)
        {
            t=a;
            a=b;
            b=t;
        }
        while(r)
        {
            r=a%b;
            j=b;
            a=b;
            b=r;
        }
        ans=c/j*d;
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 128
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int x = 0;
            int y = 0;
            int max = 0;
            boolean end = false;

            while (!end) {
                String temp = br.readLine();
                String[] numbers = temp.split(" ");
                x = Integer.parseInt(numbers[0]);
                y = Integer.parseInt(numbers[1]);

                if ((x < 0 && y > 10000) || (x == 0 && y == 0) || max > 3000) {
                    end = true;
                } else if (x > y || x == y) {
                    System.out.println(y + " " + x);
                } else if (x < y) {
                    System.out.println(x + " " + y);
                }
                max++;
            }

        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 27236
import java.io.IOException;
import java.util.Scanner;

public class Main {

	static int INF = 1 << 29;

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);
		String s1 = in.next();
		String s2 = in.next();

		// dp init
		int[][] dp = new int[s2.length()+1][s1.length()+1];
		for (int i = 0; i < s2.length(); i++) {
			for (int j = 0; j < s1.length(); j++) {
				dp[i][j] = INF;
			}
		}
		for (int i = 0; i < s1.length()+1; i++) {
			dp[0][i] = i;
		}
		for (int i = 0; i < s2.length()+1; i++) {
			dp[i][0] = i;
		}

		for (int i = 0; i < s2.length(); i++) {
			for (int j = 0; j < s1.length(); j++) {
				if (s2.substring(i, i+1).equals(s1.substring(j, j+1))) {
					dp[i+1][j+1] = Math.min(dp[i][j], Math.min(dp[i+1][j]+1, dp[i][j+1]+1));
				} else {
					dp[i+1][j+1] = Math.min(dp[i][j]+1, Math.min(dp[i+1][j]+1, dp[i][j+1]+1));
				}
			}
		}
		System.out.println(dp[s2.length()][s1.length()]);
	}
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

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

  cout << t/a * b << endl;

  return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[123];

    Scs(s);

    int leng = strlen(s) - 2;

    printf ("%c%d%c", s[0], leng , s[leng+1]);

    return 0;
}



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

struct UnionFind{
private:
  std::vector<int> data;

public:
  UnionFind(int n = 0) : data(n, -1){}

  int find(int x){
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }

  bool unite(int x, int y){
    x = find(x); y = find(y);

    if(x == y) return false;
    else{
      if(data[x] > data[y]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
      return true;
    }
  }

  bool is_same(int x, int y){
    return find(x) == find(y);
  }

  int size(int x){
    return -data[find(x)];
  }
};

using namespace std;

int main(){
  int N, M; cin >> N >> M;
  
  UnionFind uf(M);
  vector<bool> used(M, false);
  int languages = 0;
  
  int L0;
  for(int i = 0; i < N; ++i){
    int K; cin >> K;
    
    cin >> L0; --L0;
    if(!used[L0]){
      used[L0] = true;
      ++languages;
    }
    
    for(int j = 1; j < K; ++j){
      int L1; cin >> L1; --L1;
      
      if(!used[L1]){
        used[L1] = true;
        ++languages;
      }
      
      uf.unite(L0, L1);
    }
  }
  
  puts(uf.size(L0) == languages ? "YES" : "NO");
  
  return 0;
}

Measured memory_bytes: 3704
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int a, b;

  cin >> a >> b;

  int d = b - a;

  cout << (ll)d * (d+1) / 2 - b << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)





int main()
{
    int N;
    vector<int> a(N);
    int count = 0;
    cin >> N;
    rep(i,N) {
        cin >> a[i];
    }
    rep(i,N) {
        if ((i+1) % 2 != 0 && a[i] % 2 != 0) {
            count += 1;
        }
    }
    cout << count << endl;
}

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

int main() {
  int N;
  cin >> N;
  if((N % 1000) % 111 == 0 || (N % 1110) % 10 == (N % 1110)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    AB = []

    for i in range(X):
        for j in range(Y):
            AB.append(A[i]+B[j])
    AB.sort(reverse=True)
    AB = AB[:K]

    ABC = []
    for k in range(Z):
        for ab_index in range(len(AB)):
            ABC.append(C[k]+AB[ab_index])

    ABC.sort(reverse=True)
    ABC = ABC[:K]
    for i in range(len(ABC)):
        print(ABC[i])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 133992
#include<bits/stdc++.h>
using namespace std;
int main(void)
{ 
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int c = 0;int bth = 0;
    for(int  i = 0;i<n;i++)
    {
         if(s[i]=='c')
            {
               cout<<"No"<<endl;
            }
          else
            { 
                if(s[i]=='b')
                 bth++;
                if((s[i]=='a' && c<(a+b)) || (s[i]=='b' && c<(a+b) && bth<=b)){
                  cout<<"Yes"<<endl;  
                  c++;
                }
                else
                  cout<<"No"<<endl;
            }
    }
}


Measured memory_bytes: 896
n = int(input())
d = [int(i) for i in input().split()]
sorted_d = sorted(d)
center = sorted_d[int(n/2)]
if sorted_d[int(n/2-1)] == center:
    ans = 0
else:
    ans = center - sorted_d[int(n/2-1)]
print(ans)

Measured memory_bytes: 14428
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 100
#define MIN -10000
#define INF (1<<29)

int main(){
  int N,a[MAX][MAX];
  int ans = -INF;

  scanf("%d" ,&N);
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      scanf("%d" ,&a[i][j]);
      ans = max(ans,a[i][j]);
    }
  }

  for(int i = 0 ; i < N ; i++){
    int b[MAX] = {0};
    for(int j = i ; j < N ; j++){
      int sum = 0;
      for(int k = 0 ; k < N ; k++){
	b[k] += a[j][k];
	sum = max(sum + b[k] ,0);
	if(sum == 0) continue;
	ans = max(ans,sum);
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 1068
N = int(input())

ans = 1
minT, minA = 1, 1
for _ in range(N):
    T, A = map(int, input().split())
    fT, fA = (minT-1)//T+1, (minA-1)//A+1
    f = max(fT, fA)
    minT, minA = T*f, A*f
print(minT+minA)


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> v(n, vector<int>(3));
  rep (i, n) {
    rep (j, 3) {
      cin >> v[i][j];
    }
  }
  vector<vector<int>> dp(n,vector<int>(3, 0));
  dp[0][0] = v[0][0];
  dp[0][1] = v[0][1];
  dp[0][2] = v[0][2];
  rep (i, n - 1) {
    rep (j, 3) {
      rep (k, 3) {
        if (j == k) continue;
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + v[i+1][k]);
      }
    }
  }
  cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
  return 0;
}


Measured memory_bytes: 11136
N = int(input())
A = []
B = []
for i in range(N) :
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A = list(reversed(A))
B = list(reversed(B))
ans = 0
for i in range(N) :
    if (B[i] - ((A[i]+ans)%B[i])) != B[i] :
        ans += B[i] - ((A[i]+ans)%B[i])
print(ans)


Measured memory_bytes: 11840
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n+1);
	for(int i=1; i<=n; i++)cin >> a[i];
	vector<int> b=a;
	sort(b.begin(),b.end());
	for(int i=1; i<=n; i++){
		if(a[i]<b[n/2+1])cout << b[n/2+1] << endl;
		else cout << b[n/2] << endl;
	}
	return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<string.h>

int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	char a[h][w+1];
	int yoko[h],tate[w+1],i,j,counter=0,counter2=0;
	for(i=0;i<h;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<=w;j++){
			if(a[i][j]!='.')break;	
		}
		if(j==w){
			yoko[counter]=i;
			counter++;
		}
	}
	for(i=0;i<w;i++){
		for(j=0;j<h;j++){
			if(a[j][i]!='.')break;	
		}
		if(j==h){
			tate[counter2]=i;
			counter2++;
		}
	}
	int k;
	for(i=0;i<h;i++){
		for(k=0;k<counter;k++){
			if(yoko[k]==i)break;
		}
		if(k==counter){
			for(j=0;j<w;j++){
				for(k=0;k<counter2;k++){
					if(tate[k]==j)break;
				}
				if(k==counter2){
					printf("%c",a[i][j]);
				}
			}
			puts("");
		}
	}
	return 0;
}

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

int main() {

	int n, m; cin >> n >> m;
	vector<int> s(m);
	vector<char> c(m);
	for (int i = 0; i < m; i++) {
		cin >> s[i] >> c[i];
	}
	int tmp_n = n;
	int u = 1; while (tmp_n--) {u *= 10;}
	int ans = -1;
	for (int i = 0; i < u; i++) {
		string si = to_string(i);
		if (si.size() != n) continue;
		bool ok = true;
		for (int j = 0; j < m; j++) {
			if (!(si[s[j] - 1] == c[j])) {
				ok = false;
			}
		}
		if (ok) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll mod = 998244353;

const ll INF = 1e15;

int main() {
	ll n;
	cin >> n;
	vector<ll> vs(n + 5, 0);
	rep(i, n) cin >> vs[i];
	vector<ll> dp(n + 5, INF);
	dp[0] = 0;
	rep(i, n) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(vs[i + 1] - vs[i]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(vs[i + 2] - vs[i]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#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()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    ll a;
    string b;
    cin >> a >> b;
    ll nb = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0')*1;
    cout << a * nb / 100 << endl;
    
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>

int main(void){
  int i,cnt=1;
  char dance[100];
  scanf("%s",&dance[0]);

  for(i=0;i<strlen(dance);i++){
    if(i%2==1){
      if(dance[i]!='L' && dance[i]!='U' && dance[i]!='D')cnt=0;
    }else{
      if(dance[i]!='R' && dance[i]!='U' && dance[i]!='D')cnt=0;
    }
  }
  
  if(cnt){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return(0);
}

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

const int N = 6e5 + 9;

int n, k, _a[N], *a = _a;
char s[N];
bool o;

int main () {
	scanf("%d%d%s", &n, &k, s);
	for (int i = 0; i < n; ++i) a[i] = s[i] == 'B' ? 1 : 0;
	for (int i = 1; i <= k; ++i) {
		if (*a ^ o) {
			o ^= 1;
			a[n] = o;
			++a;
		} else {
			*a ^= 1;
		}
		if (i > n * 2 && (i & 1) == (k & 1)) break ;
	}
	for (int i = 0; i < n; ++i) putchar('A' + (a[i] ^ o));
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>  
#include <algorithm>  
#include <functional>  
#include <vector>  
#include <map>
#include <string>
#include <queue>
#include <deque> 
#include <cmath>
#include <math.h>
using namespace std;
	double pi=acos(-1);
	#define mod 1000000007
	long long int modexp(long long int a, int b){ 
	long long int t=1;
	while( b != 0){
		if( b%2 == 1)
			t = (t*a)%mod ;
		a = (a*a)%mod;
		b /= 2;
	}
	return t%mod;
}
int main(){
	//freopen("input.txt", "r", stdin);   
 	//freopen("output.txt", "w", stdout);
 	int n=1,m=1;
 	scanf("%d %d",&n,&m);
 	if(n>m){
 		int te=m;
 		m=n;
 		n=te;
 	}
 	long long int ans=1;
 	long long int f=2;
 	int i;
 	for(i=1;i<=n;i++) ans=(ans*i)%mod;
 	long long int ans2=1;
 	for(i=1;i<=m;i++) ans2=(ans2*i)%mod;
 	ans2=(ans*m)%mod;
 	if(m-n>=2) printf("0\n");
 	else if(m-n==1) printf("%lld\n",(ans*((ans*m)%mod))%mod );
 	else if(m==n) printf("%lld\n", (f*(ans*ans)%mod)%mod );
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
#define nl cout<<"\n";
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif

   int s,w;cin>>s>>w;
  	if(w>=s){cout<<"unsafe";}else{cout<<"safe";}
}

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

int f(int x) {
	int res = 0;
	while (x != 0) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

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

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

const int kMaxFace = 6;

void PushWheel(int (&array)[kMaxFace], int a, int b, int c, int d)
{
    int temp = array[a];
    array[a] = array[b];
    array[b] = array[c];
    array[c] = array[d];
    array[d] = temp;
}

class Dice
{
public:
    Dice(const int (&inputArr)[kMaxFace]);
    void Write();
    
    void Rotation(const char dir);
    int Get();

private:
    enum EFace{UP, SOUTH, EAST, WEST, NORTH, BOTTOM};
    
    Dice(){}
    int faces[kMaxFace];    // up,S,E,W,N,bottom. 
};

Dice::Dice(const int (&inputArr)[kMaxFace])
{
    for (int i=0; i<kMaxFace; ++i)
    {
        faces[i] = inputArr[i];
    }
}

void Dice::Rotation(const char dir)
{
    switch(dir)
    {
        // 5, 1, 3, 4, 6, 2. 
        case 'S': PushWheel(faces, UP, NORTH, BOTTOM, SOUTH);   break;
        case 'E': PushWheel(faces, UP, WEST, BOTTOM, EAST); break;
        case 'W': PushWheel(faces, UP, EAST, BOTTOM, WEST); break;
        case 'N': PushWheel(faces, UP, SOUTH, BOTTOM, NORTH); break;
        default:      break;
    }
}

int Dice::Get()
{
    return faces[UP];
}

int main()
{
    int faces[kMaxFace] = {0};
    for (int i=0; i<kMaxFace; ++i)
    {
        cin >> faces[i];
    }

    Dice dice(faces);
    
    string str;
    cin >> str;
    for (int i=0; i<str.length(); ++i)
    {
        dice.Rotation(str[i]);
    }
    
    cout << dice.Get() << endl;
    
    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(ll n,ll k){
	int cnt=0;
	while(n>0){
		n=n/k;
		cnt++;
	}
	cout<<cnt<<endl;
}
int main()
{
	ll n,k;
	cin>>n>>k;
	solve(n,k);
	return 0;
}

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

typedef unsigned long long int ul;

int main(){
  ul n;
  std::cin >> n;
  ul ans = 0,f,s, t;
  f = 2;
  s = 1;
      if(n == 0)
        ans = 2;
      else if(n == 1)
        ans = 1;
      else{
		for(ul i = 2; i <= n; i++){
        	t = f + s;
      		f = s;
      		s = t;
        }
      	ans = t;
      }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/ 
#include <iostream> 
#include <algorithm> 
#include <stdio.h> 
#include <cmath> 
#include <vector> 
#include <set> 
#include <map> 
#include <cstring> 
#include <unordered_map> 
#include <queue> 
#define   mod  998244353 
#define   int  long long  
#define   ld   long double 
#define   pb   push_back 
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   sz(x)  (int)x.size() 
#define   all(a) (a.begin(),a.end()) 
#define   ff   first 
#define   ss   second 
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 
 
inline void solve(){ 
    int p,n; cin>>p>>n; 
    map <int,int> cnt; 
    cnt.clear();
    for (int i=2;i*i<=n;i++){ 
        if (n%i==0) { 
            while (n%i==0) {
                cnt[i]++;
                n = n/i; 
            }
        } 
    } 
    cnt[n]++; 
    int ans=1;
    for (auto &it: cnt){
        if (it.ss>=p){
            ans *= pow(it.ff,(it.ss/p));
        }
    }
    cout << ans << endl;
} 
 
signed main() 
{ 
    int n=1; // cin>>n; 
    while (n--) solve(); 
    return 0; 
} 



/// 2 103 206 206 206 




Measured memory_bytes: 4072
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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 () {
  ll n, m;
  cin >> n >> m;
  ll m_left = m-2*n;
  cout << (m_left >= 0 ? n + m_left/4 : m/2) << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    now = S[0]
    ans = 1
    for s in S[1:]:
        if now != s:
            ans += 1
            now = s
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
    sum += T.at(i);
  }

  int M;
  cin >> M;
  vector<int> S(M);
  for (int i = 0; i < M; i++) {
    int P, X;
    cin >> P >> X;
    S.at(i) = sum-T.at(P-1)+X;
  }

  for (int i = 0; i < M; i++) {
    cout << S.at(i) << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
x=[]
y=[]
for i in range(n):
  xi,yi=map(int,input().split())
  x.append(xi)
  y.append(yi)
  
l=0
for i in range(n):
  for j in range(n):
    li=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
    l+=li
l/=n
print(l)

Measured memory_bytes: 38480
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] list = new int[n];
		for (int i = 0; i < list.length; i++) {
			list[i] = scan.nextInt();
		}
		
		int count = 0;
		outside: do {
			for (int i = 0; i < list.length; i++) {
				if (list[i] % 2 == 1) {
					break outside;
				}
				list[i] /= 2;
			}
			count++;
		} while(true);
		
		System.out.println(count);
	}
}


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

int main() {
  int32_t n;
  std::cin >> n;
  uint64_t count = 0;

  for (int32_t i = 0; i < n; i++) {
    uint64_t a;
    std::cin >> a;
    while (a % 2 == 0) {
      count++;
      a >>= 1;
    }
  }

  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define sc second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int jc[100005];
int ext_gcd(int a,int b,int &x,int &y){
    if(b==0){x=1;y=0;return a;}
    int q=a/b, g=ext_gcd(b,a-q*b,x,y), z=x-q*y;
    x=y; y=z;
    return g;
}
int inv(int a){
    int x,y;
    ext_gcd(a,mo_num,x,y);
    return (x+mo_num)%mo_num;
}
void init(int *x, int len){
    x[0]=1;
    for(int i=1;i<len;i++)x[i]=(x[i-1]*i)%mo_num;
}

int C(int r,int n){
    if(n<0||n<r||r<0)return 0;
    return (jc[n]*inv(jc[r])%mo_num)*inv(jc[n-r])%mo_num;
}

int32_t main(){
    int k,n;
    scanf("%lld%lld",&n,&k);
    init(jc,2001);
    for(int i=1;i<=k;i++){
        printf("%lld\n",C(i,n-k+1)*C(i-1,k-i+i-1)%mo_num);
    }
    return 0;
}


Measured memory_bytes: 256
import random

class  Dise:
    def __init__(self,top,flont,right,left,back,bottom):
        self.top,self.flont,self.right,self.left,self.back,self.bottom=top,flont,right,left,back,bottom
        
    def rot(self,d):
        if d=='N':
            self.top,self.flont,self.bottom,self.back=self.flont,self.bottom,self.back,self.top
        elif d=='E':
            self.top,self.right,self.bottom,self.left=self.left,self.top,self.right,self.bottom
        elif d=='S':
                self.top,self.flont,self.bottom,self.back=self.back,self.top,self.flont,self.bottom
        elif d=='W':
            self.top,self.right,self.bottom,self.left=self.right,self.bottom,self.left,self.top
    
    def gettop(self):
        return self.top
    def getfront(self):
        return self.flont
    def getright(self):
        return self.right

n=list(map(int,input().split()))
m=int(input())
dise=Dise(n[0],n[1],n[2],n[3],n[4],n[5])

for i in range(m):
    a,b=(int(x) for x in input().split())
    for j in range(1000):
        dise.rot(random.choice('NESW'))
        if a==dise.gettop() and b==dise.getfront():
            print(dise.getright())
            break

            
        


Measured memory_bytes: 8188
C = int(1e9) + 7
h, w, a, b = [int(x) for x in input().split()]

fact = [1]
for x in range(1, h + w - 2):
    fact.append((x * fact[x - 1]) % C)

factinv = [1] * (h + w - 2)
factinv[h + w - 3] = pow(fact[h + w - 3], C - 2, C)
for x in reversed(range(2, h + w - 3)):
    factinv[x] = (factinv[x + 1] * (x + 1)) % C

def nCr(n, r):
    return (fact[n] * factinv[r] * factinv[n - r]) % C

ans = 0
for i in range(b, w):
    ans = (ans + nCr(i + h - a - 1, h - a - 1) * nCr(a - 1 + w - i - 1, a - 1)) % C

print(ans)


Measured memory_bytes: 18988