akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 205

struct Point{
	double x,y;
};

int N;
int H,W;
Point point[NUM];
double Y_2[NUM];

bool rangeCheck(double tmp_y){
	return tmp_y >= 0 && tmp_y <= H;
}

void func(){

	N *= 2;

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&point[i].x,&point[i].y);
	}

	vector<double> Y_1;
	Y_1.push_back(0);
	Y_1.push_back(H);

	double tmp_y;

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

		if(point[i].x < W){

			tmp_y = point[i].y/(W-point[i].x)*W;
			if(rangeCheck(tmp_y)){
				Y_1.push_back(tmp_y);
			}

			tmp_y = (H-point[i].y)/(point[i].x-W)*W+H;
			if(rangeCheck(tmp_y)){
				Y_1.push_back(tmp_y);
			}
		}

		for(int k = 0; k < i; k++){
			if(fabs(point[i].x-point[k].x) < EPS)continue;

			tmp_y = (point[k].y-point[i].y)/(point[i].x-point[k].x)*point[i].x+point[i].y;
			if(rangeCheck(tmp_y)){
				Y_1.push_back(tmp_y);
			}
		}
	}

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

	double ans = 0,y_mid;

	for(int i = 0; i+1 < Y_1.size(); i++){
		if(fabs(Y_1[i+1]-Y_1[i]) < EPS)continue;

		y_mid = (Y_1[i]+Y_1[i+1])/2.0;

		for(int k = 0; k < N; k++){
			Y_2[k] = (y_mid-point[k].y)/(point[k].x+0.000000000001)*(point[k].x-W)+point[k].y;
			if(Y_2[k] < 0){
				Y_2[k] = 0;
			}
			if(Y_2[k] > H){
				Y_2[k] = H;
			}
		}
		Y_2[N] = 0;
		Y_2[N+1] = H;
		sort(Y_2,Y_2+N+2);

		ans += (Y_1[i+1]-Y_1[i])*(Y_2[(N+2)/2]-Y_2[(N+2)/2-1]);
	}

	ans /= H*H;

	printf("%.10lf\n",ans);
}

int main(){

	while(true){
		scanf("%d %d %d",&W,&H,&N);
		if(W == 0 && H == 0 && N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3444
#include <stdio.h>
int main()
{
    int n,sum=0;
    scanf("%d",&n);
    int d[n];
    for(int i=0;i<n;i++){
        scanf("%d",&d[i]);
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=d[i]*d[j];
        }
    }
    printf("%d",sum);
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2]++
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i]++
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	pfs := PrimeFactorization(n)

	cnt := 0
	for _, exp := range pfs {
		d := 1
		for d <= exp {
			exp -= d
			cnt++
			d++
		}
	}

	fmt.Println(cnt)
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);

    //できゅー
    deque<int> ans;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        if (n % 2 == 0)
        {
            if (i % 2 == 1)
            {
                ans.push_front(a.at(i));
            }
            else
            {
                ans.push_back(a.at(i));
            }
        }
        else
        {
            if (i % 2 == 0)
            {
                ans.push_front(a.at(i));
            }
            else
            {
                ans.push_back(a.at(i));
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << ans.at(i) << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define MAX 4100005
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[MAX];       //    p---|  Unit
int *left2 = new  int[MAX]; // left2 --|--------> T
int *right2 = new int[MAX]; //right2---|
int *key = new int[MAX];     // key----|
 
void Init(){
  rep(i,MAX){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
 
bool SEARCH(int x,int k){
  if(k == key[x])return true;
  if(x == NIL)return false;
  if(k < key[x])return SEARCH(left2[x],k);
  else return SEARCH(right2[x],k);
}

 
void TREE_INSERT(int z){
  int y = NIL;  
  int x = root;
 
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
 
}
 
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
 
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
 
 
int main(){
  int val;
  string op;
  long long zr;                     
 
 
  scanf("%d",&n);
  Init();  
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;         
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
    else if(op == "find"){
      scanf("%d",&val);
      if(SEARCH(root,val)){
	printf("yes\n");
      }else{
    printf("no\n");
      }
       
 
    }
  }
 
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;

  return 0;
}

Measured memory_bytes: 63000
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;

int H, W;
string s;
string mozi="snuke";
string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main()
{
	cin >> H >> W;
	for(int i=1; i<H+1; i++){
		for(int j=0; j<W; j++){
			string inp;
			cin >> inp;
			if(inp==mozi){
				cout << alpha[j] << i << endl;
				return 0;
			}
		}
	}
}


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

string s;
ll k, a, b, sol;

bool sameAll(string x) {
    for(ll i = 1; i < x.size(); i++) {
        if(x[i] != x[i - 1]) return false;
    }
    return true;
}

ll ganti(string x) {
    ll ans = 0;
    for(ll i = 0; i < x.size() - 1; i++) {
        if(x[i] == x[i + 1]) {
            ans++; i++;
        }
    }
    return ans;
}

bool BF(string x) {
    return x[0] == x[x.size() - 1];
}

ll CFront(string x) {
    ll fr = 0;
    for(ll i = 0; i < x.size(); i++) {
        if(x[i] == x[0]) fr++;
        else break;
    }
    return fr;
}

ll CBack(string x) {
    ll ba = 0;
    for(ll i = x.size() - 1; i >= 0; i--) {
        if(x[i] == x[x.size() - 1]) ba++;
        else break;
    }
    return ba;
}

void solve() {
    cin >> s >> k;
    if(sameAll(s)) cout << s.size() * k / 2 << "\n";
    else if(!BF(s)) cout << ganti(s) * k << "\n";
    else if(BF(s)) {
        a = CFront(s);
        b = CBack(s);
        sol = ganti(s) * k - (a / 2 + b / 2 - (a + b) / 2) * (k - 1);
        cout << sol << "\n";
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    solve();

}

Measured memory_bytes: 3632
S = input()

def func(s, remain):
    if not s:
        if remain:
            return min(remain)
        else:
            return -1

    T = func(s[1:], remain - set([s[0]]))
    if T == -1:
        cand = [x for x in remain if x > s[0]]
        if cand:
            return min(cand)
        else:
            return -1
    return s[0] + T


rem = set()
for i in range(26):
    rem.add(chr(ord('a') + i))

print(func(S, rem))


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

using namespace std;
#define ll long long int

int main()
{
    ll t;
    t = 1;
    // cin t;
    while (t--)
    {
        ll k;
        cin >> k;
        string s;
        cin >> s;
        if (s.length() <= k)
            cout << s << endl;
        else
        {
            string ans = "";
            for (int i = 0; i < k; i++)
                ans += s[i];
            cout << ans << "..." << endl;
        }
    }
}


Measured memory_bytes: 3608
function Main(input){
	'use strict'
	const S = [...input.trim()];
	let c0=0;
	let c1=0;

	S.forEach((v)=>{
		if(v=="0") c0++;
		else c1++;
	});
	console.log(Math.min(c0,c1)*2);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 19372
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <int,int>
#define N 300005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int A[N];
int main()
{
	int n, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
		if(A[i] < 0)
		{
			A[i] = -A[i];
			cnt++;
		}
	}
	sort(A, A + n);
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if(i == 0)
		{
			if(cnt & 1)
				ans += -A[i];
			else
				ans += A[i];
		}
		else
		{
			ans += A[i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
import copy

def BubbleSort(C, N):
    for i in range(0,N):
        for j in range(N-1,i,-1):
            if C[j][1:] < C[j-1][1:]:
                #  C[j] と C[j-1] を交換
                C[j] , C[j-1] = C[j-1] , C[j]
    ret = " ".join(C)
    print(ret)
    print("Stable")
    return ret

def SelectionSort(C, N):
    for i in range(0,N):
        minj = i
        for j in range(i,N):
            if C[j][1:] < C[minj][1:]:
                minj = j
        # C[i] と C[minj] を交換
        C[i] , C[minj] = C[minj] , C[i]
    ret = " ".join(C)
    print(ret)
    return ret

N = int(input())
C = input().split(" ")
ret_B = BubbleSort(copy.deepcopy(C),N)
ret_S = SelectionSort(copy.deepcopy(C),N)
if ret_B == ret_S:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a, b;
    cin >> a >> b;
    a--;
    int cnt = 0;
    while(cnt * a + 1 < b) cnt++;
    cout << cnt << endl;
}

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


Measured memory_bytes: 3612
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
cnt = 0
for a in range(1,K+1) :
    for b in range(a,K+1) :
        for c in range(b,K+1) :
            if a == b and b == c :
                cnt += gcd(a,b,c)
            elif (a == b and b != c) or (a == c and c != a) or (b == c and a != b) :
                cnt += 3 * gcd(a,b,c)
            else :
                cnt += 6 * gcd(a,b,c)

print(cnt)


Measured memory_bytes: 9628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] cf = {1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81};
        boolean ok = false;
        
        for(int i = 0; i < cf.length;i++){
            if(n == cf[i]) ok = true;
        }
        
        if(ok){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a*b << ' ' << 2*(a+b) << endl;
}


Measured memory_bytes: 3056
var
	n,m,i,j,k,s,t:Longint;
	a,b,c,d:array[1..50]of Longint;
begin
	read(n,m);
	for i:=1 to n do read(a[i],b[i]);
	for i:=1 to m do read(c[i],d[i]);
	for i:=1 to n do begin
		s:=1000000000;
		for j:=1 to m do begin
			if a[i]>c[j] then t:=a[i]-c[j] else t:=c[j]-a[i];
			if b[i]>d[j] then inc(t,b[i]-d[j]) else inc(t,d[j]-b[i]);
			if s>t then begin
				s:=t;
				k:=j;
			end;
		end;
		writeln(k);
	end;
end.


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

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

    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    buf.pop();
    let X = i64::from_str(&buf).unwrap();
    let mut money = 100;
    let mut cnt = 1;
    loop {
        money = money + (money/100);
        if money >= X {
            println!("{}", cnt);
            return ();
        }
        cnt += 1;
    }
}


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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)

#define pb push_back
#define pf push_front
#define mp make_pair
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define VL vector<long long>
#define F first
#define S second

using namespace std;


typedef complex<double> P;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }
inline int gcd(int a, int b) {
    if (b == 0) return a;
    return a < b? gcd(b, a) : gcd(b, a % b);
}
ll mo=1000000007;
const ll INF = 1e18;

int main(){
    string n;
    cin >> n;

    int sz = SZ(n);
    /**
        a   b   c   d   e
1e0    2^3 2^3 2^3 2^3 2^4 -> (0) 3 3 3 3 4
1e1    2^2 2^2 2^2 2^3        (1) 2 2 2 3
1e2    2^1 2^1 2^2            (2) 1 1 2
1e3    2^0 2^1                (3) 0 1
1e4    2^0                    (4) 0
        a   b   c   d
1e0    2^2 2^2 2^2 2^3     -> (0) 2 2 2 3
1e1    2^1 2^1 2^2            (1) 1 1 2
1e2    2^0 2^1                (2) 0 1
1e3    2^0                    (3) 0

    */
    vector<vector<int> > cnts;


    FO(i, sz) {
        vector<int> vct(sz - i);
        FO(j, sz - i) {
            if (j == sz - i - 1) {
                vct.at(j) = sz - 1 - i;
            } else {
                vct.at(j) = sz - 2 - i;
            }
        }
        cnts.pb(vct);
    }

    ll sum = 0;

    FO(i, sz) {
        ll ele1 = n.at(i) - '0';
        ll ele2 = 0;
        FO(j, sz - i) {
            ele2 += (pow(10, j) * pow(2, cnts.at(j).at(i)));
        }
        sum += (ele1 * ele2);
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}




int main()
{
    init();
    int n ;
    cin>>n;
    string arr[n];
    long long x=0;
     map<string,long long>mp;
    for(int i =0;i<n;i++){
     cin>>arr[i];
    sort(arr[i].begin(), arr[i].end());
    mp[arr[i]]++;
    //if(mp[arr[i]]>1){
     //    x++;
   //  }

     }
    for(int i =0;i<n;i++){
        if(mp[arr[i]]>1){ x+=(mp[arr[i]]*(mp[arr[i]]-1))/2;
        mp[arr[i]]=0;
        }
    }




     cout<<x;
    }


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  string s;
  cin >> s;
  string t = "";
  t += 's';
  if (s[s.size()-1] == 's') t = "es";
  cout << s << t << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			100011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
 
}

ll a[M];


int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n>>m;
    lp(1,n)cin>>a[i];
    vector<pii> v;
    while(m--){
    	cin>>x>>y;
    	v.pb({-y,x});
    }
    sort(all(v));
    priority_queue<ll,vector<ll>,greater<ll> > pq;
    lp(1,n)pq.push(a[i]);
    p=0;
    for(auto x:v){
    	ll c=pq.top();
    	if(-x.F<c)break;
    	ll b=x.S;
    	while(pq.size()&&pq.top()<-x.F&&b){
    		p+=-x.F;
    		--b;
    		pq.pop();
    	}
    }
    while(pq.size())p+=pq.top(),pq.pop();
   	cout<<p<<"\n";


}



Measured memory_bytes: 4464
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    LL L, R;
    cin >> L >> R;

    if(R >= L+2019){
        cout << 0 << endl;
        return 0;
    }

    priority_queue<LL, vector<LL>, greater<LL>> que;
    for(LL i=L; i<=R; i++){
        for(LL j=i+1; j<=R; j++){
            LL r1 = i%2019;
            LL r2 = j%2019;
            que.push((r1*r2)%2019);
        }
    }

    LL ans = que.top();
    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 19700
s = str(input())
lis = [1 for i in range(len(s))]
n = len(s)
li = []
l = []
key = 0
num = 0
for i in range(n-1):
    l.append(s[i])
    if s[i] == "L":
        key = 1
    if s[i+1] == "R" and key == 1:
        li.append(l)
        l = []
        key = 0
l.append("L")
li.append(l)

ans = ""

for ss in li:
    if len(ss) % 2 == 0:
        ans += "0 " * (ss.count("R")-1) + (str(len(ss)//2)+" ") * 2 + "0 " * (ss.count("L")-1)
    else:
        ans += "0 " * (ss.count("R")-1) + (str(len(ss)//2 + ss.count("R")%2)+" ") + (str(len(ss)//2 + ss.count("L")%2)+" ")  + "0 " * (ss.count("L")-1)
print(ans)

Measured memory_bytes: 10364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>

using namespace std;

int main() {

	int n, l;
	string str;
	vector<string> s;

	cin >> n >> l;

	for (int i = 0; i < n; i++) {
		cin >> str;
		s.push_back(str);
	}

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

	ostringstream os;
	std::copy(s.begin(), s.end(), std::ostream_iterator<std::string>(os));

	std::string ans = os.str(); 
	
	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 256
//
// Created by admin on 2020/5/30.
//
#include <bits/stdc++.h>
using namespace std;
long long k;
struct clocks
{
    long long h,m;
}a1,a2;
int cacu()
{
    return a2.h*60+a2.m-a1.h*60-a1.m;
}
int main()
{
    cin>>a1.h>>a1.m>>a2.h>>a2.m;
    cin>>k;
    cout<<cacu()-k<<endl;
    return 0;
}


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

typedef long long LL;
const int INF=0x3f3f3f3f;
int num[111];

int main(){
    int n,tmp;
    int ans=1,res=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>tmp;
        if(tmp%2) num[i]=1;
        else num[i]=2;
    }
    for(int i=0;i<n;i++){
        ans*=num[i];
        res*=3;
    }
    cout<<res-ans<<endl;
    return 0;
}


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

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

    int res = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((p[i] > p[i - 1] && p[i] < p[i + 1]) || (p[i] < p[i - 1] && p[i] > p[i + 1]))
            res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,-1,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
 
ld po(ld a,ld b)
{
  return pow(a,b);
}
int main()
{
  //fopen();
  ld a,b,c;
  cin>>a>>b>>c;
  if(c<a+b)
  {
    cout<<"No";return 0;
  }
  ld p=c-a-b;
  ld q=p*p;
  p=4*a*b;
  if(p<q)
  {
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  //cout<<(p>po(c,0.5))?"Yes":"No";
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main()
{
	int X=0 ;
	cin >> X ;
	switch(X%7)
	{
	case 0:
		cout << "thu" << endl ;
		break ;
	case 1:
		cout << "fri" << endl ;
		break ;
	case 2:
		cout << "sat" << endl ;
		break ;
	case 3:
		cout << "sun" << endl ;
		break ;
	case 4:
		cout << "mon" << endl ;
		break ;
	case 5:
		cout << "tue" << endl ;
		break ;
	case 6:
		cout << "wed" << endl ;
		break ;
	}
	return 0 ;
}



Measured memory_bytes: 3112
#include <stdio.h>
#include <math.h>

int main(void)
{
    double a, b, c, d, e, f, m, x, y;

    while (scanf("%lf %lf %lf %lf %lf %lf"
    , &a, &b, &c, &d, &e, &f) != EOF){

        y = (c * d - a * f) / (b * d - a * e);
		x = (c - b * y) / (a);

		printf("%.3f %.3f\n", x, y);
    }

    return (0);
}



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

int main(void){
    /*  A=0, B=1
        X=2, Y=3, Z=4, W=5    */
    int d[7][2];
    for(int i=0; i<=6; i++){
        d[i][0]=d[i][1]=6;
    }
    d[0][0]=2; d[0][1]=3; d[3][0]=2;
    d[2][1]=4; d[1][1]=2; d[1][0]=3; d[5][1]=3;
    d[4][0]=5; d[4][1]=1; d[5][0]=1;
    string s;
    while(cin>>s){
        if(s=="#") break;
        int now=0;
        for(int i=0; i<s.length(); i++){
            now=d[now][s[i]-'0'];
        }
        cout << (now==1? "Yes":"No") << "\n";
    }
    
}



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

int main(){
  int sunuke[102];
  int N, K;
  int d, i, ans, t, j;
  sunuke[0] = 1;
  for(i=1; i<=101; i++){
    sunuke[i] = 0;
  }

  scanf("%d %d", &N, &K);
  for(i=0; i<K; i++){
      scanf("%d", &d);
      for(j=0; j<d; j++){
        scanf("%d", &t);
        sunuke[t] = 1;
      }
  }

  ans = 0;
  for(i=0; i<N+1; i++){
    if(sunuke[i] == 0)ans++;
  }
  printf("%d\n", ans);

}

Measured memory_bytes: 1736
def quicksort(A, p, r):
    if p < r:
        q = patation(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)

def patation(A, p, r):
    x = int(A[r][1])
    i = p - 1
    for j in range(p, r):
        if int(A[j][1]) <= x:
            i += 1
            tmp = A[i]; A[i] = A[j]; A[j] = tmp
    tmp = A[i+1]; A[i+1] = A[r]; A[r] = tmp
    return i+1

def print_list(A):
    if A == B:
        print("Stable")
    else:
        print("Not stable")

    for line in A:
        print(line[0], line[1])

A = []
n = int(input())
for i in range(n):
    A.append(input().split())
B = sorted(A, key=lambda x: x[1])
p = 0; r = n - 1
quicksort(A, p, r)
print_list(A)



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

import sys
input=sys.stdin.readline

n,q=map(int,input().split())
left=n
up=n
ans=(n-2)*(n-2)
fixed_yoko=[0]*(n+1)
fixed_tate=[0]*(n+1)
post_process=[]
for _ in range(q):
    t,x=map(int,input().split())
    if t==1:
        if x>left:
            post_process.append((t,x))
        else:
            fixed_yoko[left]+=-up
            fixed_yoko[x+1]+=up
            ans-=up-2
            left=x
    elif t==2:
        if x>up:
            post_process.append((t,x))
        else:
            fixed_tate[up]+=-left
            fixed_tate[x+1]+=left
            ans-=left-2
            up=x
for i in range(1,n+1):
    fixed_yoko[i]+=fixed_yoko[i-1]
    fixed_tate[i]+=fixed_tate[i-1]
for t,x in post_process:
    if t==1:
        ans-=fixed_yoko[x]-2
    elif t==2:
        ans-=fixed_tate[x]-2
print(ans)

Measured memory_bytes: 45472
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)

using namespace std;

typedef long long LL;
LL A, B, C, D, g, mx;

LL gcd(LL a, LL b) {return b? gcd(b, a % b): a;}

int main() {
	int T;
	scanf("%d", &T);
	while(T--) {
		scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
		if(A < B) {puts("No"); continue;}
		if(D < B) {puts("No"); continue;}
		if(C >= B) {puts("Yes"); continue;}
		g = gcd(B, D);
		mx = (B - A%B - 1) / g * g + A%B;
		if(mx > C) puts("No"); else puts("Yes");
	}
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    ll cnt = 0;
    for(int i = 0;i * R <= N;i++){
        for(int j = 0;i * R + j * G <= N;j++){
            //if(i * R + j * G > N)break;
            ll nu = i * R + j * G;
            if((N - nu) % B == 0)cnt++;
            /*
            for(int k = 0;k * B <= N;k++){
                ll num = i * R + j * G + k * B;
                if(num > N)break;
                if(num >= 0 && num < N)cnt++;
            }
            */
        }
    }
    cout << cnt << endl;
}

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

int main() {
  int n; cin >> n;
  vector<int> ans;
  for (int i = 2; i <= 55555; i ++) {
    if (i % 5 == 1) {
      bool flag = true;
      for (int j = 2; j * j <= i; j ++) {
        if (i % j == 0) flag = false;
      }
      if (flag) ans.push_back(i);
    }
  }

  rep(i, n) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

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

	int[] a = new int[3];
	for(int i = 0; i < 3; i++){
	    a[i] = scan.nextInt();
	}

	Arrays.sort(a);
	System.out.print(a[2]-a[0]);
    }
}
	


Measured memory_bytes: 21844
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


template<typename T>
vector<vector<T>> keisann(const vector<vector<T>>l, const vector<vector<T>>r) {
	vector<vector<T>>ans(l.size(), vector<T>(r[0].size()));
	assert(l[0].size() == r.size());
	for (unsigned int h = 0; h < l.size(); ++h) {
		for (unsigned int i = 0; i < r.size(); ++i) {
			for (unsigned int w = 0; w < r[0].size(); ++w) {

				ans[h][w] |= l[h][i] * r[i][w];
			}
		}
	}
	return ans;
}

template<typename T>
vector<vector<T>>powgyou(vector<vector<T>>a, const long long int n) {
	assert(a.size() == a[0].size());
	if (!n) {
		vector<vector<T>>e(a.size(), vector<T>(a[0].size()));
		for (unsigned int i = 0; i < a.size(); ++i) {
			e[i][i] = 1;
		}
		return e;
	}
	if (n == 1)return a;
	else {
		vector<vector<T>>ans(a.size(), vector<T>(a[0].size(), 0));
		ans = powgyou(a, n / 2);
		ans = keisann(ans, ans);
		if (n % 2) {
			ans = keisann(ans, a);
		}
		return ans;
	}
}


int main() {
	while (1) {
		int N, M, Z; cin >> N >> M >> Z;
		if (!N)break;
		vector<pair<int, int>>edges;
		edges.push_back(make_pair(-1, 0));
		for (int i = 0; i < M; ++i) {
			int s, d; cin >> s >> d; s--; d--;
			edges.push_back(make_pair(s, d));
			edges.push_back(make_pair(d, s));
		}
		vector<vector<int>>field(edges.size(), vector<int>(edges.size()));
		for (int i = 0; i < edges.size(); ++i) {
			for (int j = 0; j <edges.size(); ++j) {
				auto a = edges[i];
				auto b = edges[j];
				if (a.second == b.first&&a.first != b.second) {
					field[j][i] = true;
				}
			}
		}
		vector<vector<int>>start(edges.size(), vector<int>(1));
		start[0][0] = true;
		vector<vector<int>>kake = powgyou<int>(field, Z);
		vector<vector<int>>ans = keisann<int>(kake, start);
		bool ok = false;
		for (int i = 0; i <edges.size(); ++i) {
			if (edges[i].second == N - 1 && ans[i][0])ok = true;
		}
		if (ok)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			map = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = scanner.nextInt();
				}
			}
			int[][] dp = new int[h][w];
			for (int i = 0; i < w; i++) {
				if (map[0][i] == 0)
					dp[0][i] = 1;
			}
			for (int i = 1; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (map[i][j] == 0) {
						if (j > 0 && map[i - 1][j - 1] == 0)
							dp[i][j] += dp[i - 1][j - 1];
						if (j < w-1 && map[i - 1][j + 1] == 0)
							dp[i][j] += dp[i - 1][j + 1];
						if (map[i - 1][j] == 0)
							dp[i][j] += dp[i - 1][j];
						if (i > 1 && map[i - 2][j] == 2)
							dp[i][j] += dp[i - 2][j];
					} else if (map[i][j] == 2) {
						if (map[i - 1][j] == 0)
							dp[i][j] += dp[i - 1][j];
						if (i > 1 && map[i - 2][j] == 2)
							dp[i][j] += dp[i - 2][j];
					}
				}
			}
			int sum = 0;
			for (int i = 0; i < w; i++) {
				sum += dp[h - 1][i];
				if (h > 1 && map[h - 2][i] == 2)
					sum += dp[h - 2][i];
			}
			System.out.println(sum);
		}
	}

	int count;
	int w;
	int h;
	int[][] map;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        String s = sc.next();
        int pop = 0;
        for (int i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == '1') {
                pop++;
            }
        }
        int below = 0; int above = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '1') {
                if (pop != 1) below = (below + pow(2, n - 1 - i, pop - 1)) % (pop - 1);
                above = (above + pow(2, n - 1 - i, pop + 1)) % (pop + 1);
            }
        }
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '1') {
                if (pop == 1) {
                    out.println(0); continue;
                }
                int use = below;
                use = (use - pow(2, n - 1 - i, pop - 1)) % (pop - 1);
                if (use < 0) use += (pop - 1);
                int ans = 1;
                while (use != 0) {
                    use = use % Integer.bitCount(use);
                    ans++;
                }
                out.println(ans);
            } else {
                int use = above;
                use = (use + pow(2, n - 1 - i, pop + 1)) % (pop + 1);
                if (use < 0) use += (pop + 1);
                int ans = 1;
                while (use != 0) {
                    use = use % Integer.bitCount(use);
                    ans++;
                }
                out.println(ans);
            }
        }
        out.close();
    }

    static int pow(long b, int e, int mod) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return (int) ans;
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 48048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr << #x << " = " << x << endl

int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	string s;
	cin >> s;
	int n = s.length();
	function<bool(string)> is_palindrome = [](const string &s) -> bool {
		int n = s.length();
		for(int i=0; i<n/2; i++)
			if(s[i] != s[n-i-1])
				return false;
		return true;
	};
	cout << (is_palindrome(s) && is_palindrome(s.substr(0, (n-1)/2)) && is_palindrome(s.substr((n+2)/2))? "Yes\n": "No\n");
	
	return 0;
}

Measured memory_bytes: 3636
/*
AizuOnline A1020
Title Cleaning Robot
6/11 WA
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
// p[from_state][to_state]
//state 0:A,1:B,2:C
//      
int n;
char s,t,b;      
double p[16][9];
int tr0[9][9]={{2,1,0,1,0,0,0,0,0},
              {1,1,1,0,1,0,0,0,0},
              {0,1,2,0,0,1,0,0,0},
              {1,0,0,1,1,0,1,0,0},
              {0,1,0,1,0,1,0,1,0},
              {0,0,1,0,1,1,0,0,1},
              {0,0,0,1,0,0,2,1,0},
              {0,0,0,0,1,0,1,1,1},
              {0,0,0,0,0,1,0,1,2}};
int tr[9][9];
//
void init()
{
        int i;

        for(i=0;i<9;i++)
                p[0][i]=0.0;
        p[0][s-'A']=1.0;
}
void souko()
{
        int i,j,b0;

        for(i=0;i<9;i++)
                for(j=0;j<9;j++)
                        tr[i][j]=tr0[i][j];

        b0=b-'A';
        for(i=0;i<9;i++)
        {
                tr[i][i] += tr[b0][i];
                tr[b0][i] = 0;
        }
}
void show(int n)
{
        printf("----------------\n");
        printf("%lf %lf %lf\n",p[n][0],p[n][1],p[n][2]);
        printf("%lf %lf %lf\n",p[n][3],p[n][4],p[n][5]);
        printf("%lf %lf %lf\n",p[n][6],p[n][7],p[n][8]);
}

main()
{
        int i,j,k;
        double sum;
        
        while(scanf("%d ",&n) && n)
        {
                scanf("%c %c %c",&s,&t,&b);
                init();
                souko();

                //show(0);
                for(i=0;i<n;i++)
                {                        
                        for(j=0;j<9;j++)
                        {
                                sum=0.0;
                                for(k=0;k<9;k++)
                                        sum += (double)tr[j][k]/4.0*p[i][k];
                                p[i+1][j]=sum;
                        }
                        //show(i+1);
                }

                printf("%0.8lf\n",p[n][t-'A']);
        }
return(0);
}

Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;

class Main {

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

    public static void main(String[] args) {
        int n = sc.nextInt();
        HashSet<Integer> mochi = new HashSet<>();
        for (int i = 0; i < n; i++) {
            mochi.add(sc.nextInt());
        }
        System.out.println(mochi.size());
    }
}

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a<=0&&0<=b)
		cout<<"Zero"<<endl;
	else if(a>0||((b-a)&1)==1)
		cout<<"Positive"<<endl;
	else 
		cout<<"Negative"<<endl;
}


Measured memory_bytes: 256
"""
問題文を言い換えると、「最大公約数が最大になるように数字を一つ書き換えろ」ということ。
さらに言い換えると、「最大公約数が最大になるように数字を一つ消せ」ということ。
単純な線形探索でできるか？→NO

最大公約数を小さくする要因となっている数字を一つ消す。
どういう数字が最大公約数を小さくする要因になっているか？
他の数字と共通する素因数が少ない、小さい、次数が小さい。ただ、この3つを総合的に判断するのは難しすぎる。
素因数分解はやめて、単純に約数で探せばよいか。
各Aの約数を昇順で列挙しておく。
まずA1は必ず残すと仮定して、A1の約数の大きい方から順番に、ほかのAの約数になるかどうかを調べる。
その約数を含んでいないAが一つだけ存在するとき、そのAを消せば、その約数が最大公約数となる。

次に、A1を消す場合の最大公約数も求めて、A1を含める場合の最大公約数と比較して大きい方を採用する。
"""

N = int(input())
A = list(map(int,input().split()))

#A1を必ず入れる場合の最大公約数を求める。
yakusu = []

a = A[0]
d = 1
while d*d < a:
    if a % d == 0:
        yakusu.append(d)
        yakusu.append(a//d)
    d += 1
if d*d == a:
    yakusu.append(d)
yakusu.sort(reverse=True)

ans = 1
for v in yakusu:
    cnt = 0
    for i in range(1,N):
        if A[i]%v != 0:
            cnt += 1
    if cnt <= 1:
        ans = v
        break

#A1を入れない場合の最大公約数を求める。
import math
g = A[1]
for i in range(2,N):
    g = math.gcd(g,A[i])

ans = max(ans,g)

print(ans)


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

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

	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}
	}

	cout << "NG";
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;
using ll = long long;

static ll grundy(ll a, ll k){
	while(a % k != 0){
		const ll t = a / k;
		const ll x = (a - t * k + t) / (t + 1);
		a -= x * (t + 1);
	}
	return a / k;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	ll g = 0;
	for(int i = 0; i < n; ++i){
		ll a, k;
		cin >> a >> k;
		g ^= grundy(a, k);
	}
	if(g == 0){
		cout << "Aoki" << endl;
	}else{
		cout << "Takahashi" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

const int INF=1000000000+7;

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int n,w;
		cin>>n>>w;
		ll a[n][2];
		fi(0,n)
		{
			cin>>a[i][0]>>a[i][1];
		}
		ll dp[100000+2];
		fill(dp,dp+100002,INF);
		dp[0]=0;
		fi(0,n)
		{
			for(int j=100001;j>=0;j--)
			{
				if(j-a[i][1]>=0)
				dp[j]=min(dp[j],dp[j-a[i][1]]+a[i][0]);
			}
		}
		int ans=0;
		for(int i=100001;i>=0;i--)
		{
			if(dp[i]<=w)
			{
				ans=i;
				break;
			}
		}
		cout<<ans;
		
		
	}
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

class Bridges {
public:
  int n;
  vector<vector<int>> G;
  vector<bool> visited;
  vector<int> prenum, parent, lowest;
  int timer;
  set<pair<int, int>> bd;

  Bridges() {}
  Bridges(int n_, vector<vector<int>> G_) {init(n_, G_);}

  void init(int n_, vector<vector<int>> G_) {
    n = n_;
    G = G_;
    visited.resize(n, false);
    prenum.resize(n, 0);
    parent.resize(n, 0);
    lowest.resize(n, 0);
    timer = 1;
    find();
  }

  void dfs(int current, int prev) {
    prenum[current] = lowest[current] = timer;
    timer++;
    visited[current] = true;
    for (int next: G[current]) {
      if (!visited[next]) {
        parent[next] = current;
        dfs(next, current);
        chmin(lowest[current], lowest[next]);
        if (prenum[current] < lowest[next]) {
          bd.insert({min(current, next), max(current, next)});
        }
      }
      else if (next != prev) {
        chmin(lowest[current], prenum[next]);
      }
    }
  }

  void find() {
    dfs(0, -1);
  }
};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, m;
  cin >> n >> m;
  vector<vector<int>> G(n);
  rep(i, m) {
    int s, t;
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  Bridges bd(n ,G);
  auto ans = bd.bd;
  for (auto x: ans) cout << x.first << ' ' << x.second << '\n';

  
  return 0;
}


Measured memory_bytes: 6728
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,e,k;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  cin>>e;
  cin>>k;
  int n=e-a;
  if(n>k){
	cout<<":("<<endl;
  }else{
	cout<<"Yay!"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N,K,h;
	cin>>N>>K;
	int ans=0;
	for (int i=0;i<N;i++){
		cin>>h;
		if (h>=K){
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np
A, B, H, M = map(int, input().split())

ans = 0
t = 60 * H + M #分
h_a = 0.5
m_a = 6
angle = (5.5 * t) % 360

if angle > 180:
    angle = 360 - angle
    ans = A ** 2 + B ** 2 - 2 * A * B * np.cos(np.radians(angle))
    print(np.sqrt(ans))
else:
    ans = A ** 2 + B ** 2 - 2 * A * B * np.cos(np.radians(angle))
    print(np.sqrt(ans))


Measured memory_bytes: 27208
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)



int main() {
    ll n, a[100000], sum = 0;
    
    cin >> n;
    REP(i, n){
        cin >> a[i];
        
        sum += a[i];
    }
    
    sort(a, a + n, greater<ll>());
    
    ll ans = 1;
    sum -= a[0];
    for(int i = 1; i < n; i++){
        if(sum * 2 >= a[i - 1]){
            ans++;
            sum -= a[i];
        }
        else{
            break;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1024