akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int n,d;
    scanf("%d %d ",&n,&d);
   int data[n][d];
   int i,j,m;
   for (i=0;i<n;i++){
       for(j=0;j<d;j++){
           scanf("%d",&data[i][j]);
       }
   }
   int ans=0,dis=0;
   for(i=0;i<n;i++){
       for(j=0;j<i;j++){
           dis=0;
           for(m=0;m<d;m++){
               dis+=pow(data[i][m]-data[j][m],2);
           }
          //printf("%d\n",dis);
        if(dis==pow((float)(sqrt(dis)),2)){ans++;}
       }
      
   }
   printf("%d\n",ans);
    return(0);
}


Measured memory_bytes: 128
'use strict';
const main = input => {
  input = input[0].split(' ').map(val => parseInt(val));
  let ans = input.reduce((prev, current) => prev + current);  
  ans += Math.max(...input)*9;
  // console.log(input);
  
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
const int N=4000002;
char s[N],t[N];
int a,b,ne[N],ans,g[N],i,j;
int main(){
	scanf("%s%s",s+1,t+1),a=strlen(s+1),b=strlen(t+1);
	for (;a<b*2;a*=2)
		for (i=1;i<=a;i++) s[i+a]=s[i];
	for (i=1;i<=a;i++) s[i+a]=s[i];
	a*=2;
	for (i=1;i<=b;i++){
		j=i;
		while (j>1 && t[ne[j-1]]!=t[i]) j=ne[j-1]-1;
		ne[i]=ne[j-1]+1;
	}
	for (i=1,j=1;i<=a;i++){
		while (j>1 && s[i]!=t[j]) j=ne[j-1];
		if (s[i]==t[j]) j++;
		if (j==b+1) ans=max(ans,g[i]=g[i-b]+1);
	}
	printf("%d",ans>=a/b-1?-1:ans);
}


Measured memory_bytes: 23040
from functools import reduce

MOD = 1000000007

def comb(n, r):
    if n < 0 or r < 0 or r > n:
        return 0
    r = min(r, n - r)
    if r == 0: return 1

    numer = [n - r + i + 1 for i in range(r)]
    denom = [i + 1 for i in range(r)]

    for i in range(1, r):
        divisor = denom[i]
        if divisor > 1:
            offset = (n - r) % (i + 1)
            for j in range(i, r, i+1):
                numer[j - offset] //= divisor
                denom[j] //= divisor

    # res = 1
    # for i in range(r):
    #     if numer[i] > 1:
    #         res *= numer[i]
    # return res

    return reduce(lambda x, y: x*y if y > 1 else x, numer)
    # return reduce(mul, numer)

def main():
    x, y = map(int, input().split())
    ans = 0
    if (x+y)%3==0 and x <= 2*y <= 4*x:
        n = (x + y) // 3
        r = y - n
        ans = comb(n, r) % MOD
    print(ans)

if __name__ == "__main__":
    import sys
    if sys.platform =='ios':
        sys.stdin=open('in.txt')
    sys.setrecursionlimit(10**6)
    main()


Measured memory_bytes: 65164
import Control.Monad (replicateM)
import Data.Array (Array,listArray,(!),(//))

type Column = Int
type Danger = Int
type Stone = (Column,Danger)

type Point = Int
type PointMatrix = Array Int [Point]

main = do
    [n,m] <- getLine >>= return . map read . words
    if all (==0) [n,m] then return () else do
        st <- readStones n
        print $ solve m st
        main

readStones :: Int -> IO [[Stone]]
readStones n = replicateM n readRow
    where
    readRow = do
        nums <- getLine >>= return . map read . words
        return (stones (tail nums))

    stones [] = []
    stones (c:d:ns) = (c,d) : stones ns

solve :: Int -> [[Stone]] -> Point
solve m (r2:r1:rs) = pm1 `seq` pm2 `seq` step rs r1 r2 pm1 pm2
    where
    pm2 = (listArray (0,m) (repeat [])) // [(m, map (const 0) r2)]

    pm1 | m == 0 = (listArray (0,m) (repeat [])) //
            [(m, ((r2,pm2) %% m) <*> r1)]
        | otherwise = (listArray (0,m) (repeat [])) //
            [(m, ((r2,pm2) %% m) <*> r1), (m-1, map (const 0) r1)]

    step [] r1 r2 pm1 pm2 = case (ps1,ps2) of
            ([],[]) -> -1
            (ps,[]) -> minimum ps
            ([],ps) -> minimum ps
            (ps1,ps2) -> min (minimum ps1) (minimum ps2)
        where
        ps1 = concatMap (pm1!) [0..m]
        ps2 = concatMap (pm2!) [1..m]

    step (r0:rs) r1 r2 pm1 pm2 = pm0 `seq` step rs r0 r1 pm0 pm1
        where
        pm0 = listArray (0,m) (map points [0..m])
        points m'
            | m' == m = ((r1,pm1) %% m') <*> r0
            | otherwise = takeMin
                    (((r1,pm1) %% m') <*> r0)
                    (((r2,pm2) %% (m'+1)) <*> r0)

        takeMin [] xs = xs
        takeMin xs [] = xs
        takeMin xs ys = zipWith min xs ys

    (%%) :: ([Stone],PointMatrix) -> Int -> [(Stone,Point)]
    (r,pm) %% m = zip r (pm!m)

    (<*>) :: [(Stone,Point)] -> [Stone] -> [Point]
    [] <*> _ = []
    prevs <*> currs = map safest currs
        where
        safest curr = minimum $ map (`newPoint` curr) prevs
        newPoint ((c1,d1),p1) (c0,d0) = p1 + (d0+d1) * (abs (c0-c1))

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    if (!(x % y)) cout << -1 << endl;
    else cout << x * (y + 1) << endl;
    
    return 0;
}



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


int square[] = { 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289 };
int ans;


void dfs(int num, int upper){
	//cout << num << "\t" << upper << endl;

	for (int i = upper; i >= 0; i--){
		if (num > square[i]) dfs(num - square[i], i);
		else if (num == square[i]) ans++;
	}

	return;
}


int main(void){

	int num;

	while (cin >> num, num){
		ans = 0;
		dfs(num, 16);

		cout << ans << endl;

	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
  
int main() {
  int n, a, b, pointA, pointB;
 
  cin >> n;
  while (n != 0) {
     
 
    pointA = 0;
    pointB = 0;
 
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
  
      if (a > b) {
        pointA += (a + b);
      } else if (a < b) {
        pointB += (a + b);
      } else {
        pointA += a;
        pointB += b;
      }
    }
 
    cout << pointA << ' ' << pointB << endl;
    cin >> n;
  }   
  
  return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>
int n, d, x, y, z, e, f, k;
char s[200000];
int u[200000];
int v[200000];
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	for (int i = 0; i < n; i++) {
		if (s[i] == '1')d++;
	}
	if (d > 1) {
		for (int i = 0; i < n; i++) {
			x *= 2;
			x += s[i] - '0';
			x %= (d - 1);
		}
	}
	if (d > 1) {
		u[n - 1] = 1;
		for (int i = n - 1; i; i--) {
			u[i - 1] = u[i] * 2 % (d - 1);
		}
	}
	for (int i = 0; i < n; i++) {
		y *= 2;
		y += s[i] - '0';
		y %= (d + 1);
	}
	v[n - 1] = 1;
	for (int i = n - 1; i; i--) {
		v[i - 1] = v[i] * 2 % (d + 1);
	}
	for (int i = 0; i < n; i++) {
		z = 1;
		if (s[i] - '0') {
			if (d > 1) {
				k = x + (d - 1 - u[i]);
				k %= (d - 1);
				while (k) {
					e = k;
					f = 0;
					while (e) {
						if (e % 2)f++;
						e /= 2;
					}
					k %= f;
					z++;
				}
				printf("%d\n", z);
			}
			else printf("0\n");
		}
		else {
			k = y + v[i];
			k %= (d + 1);
			while (k) {
				e = k;
				f = 0;
				while (e) {
					if (e % 2)f++;
					e /= 2;
				}
				k %= f;
				z++;
			}
			printf("%d\n", z);
		}
	}
}

Measured memory_bytes: 3464
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long answer=0;
  long long before=0;
  for(int i=0;i<N;i++){
    long long A;
    cin>>A;
    if(A<before) answer+=before-A;
    else before=A;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
	register ll number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(register ll x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll a=read(),b=2;
    for(ll i=0;i<a;i++)
		b=(b+1)*2;
    write(b);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
// Problem : C - Snuke Festival
// Contest : AtCoder - AtCoder Beginner Contest 077
// URL : https://atcoder.jp/contests/abc077/tasks/arc084_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n; cin >> n;
    vi a(n),b(n),c(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    rep(i,0,n) cin >> c[i];    
    
    sort(all(a)) , sort(all(c));
    ll ans = 0,temp1,temp2;
    
    rep(i,0,n){
        auto it1 = lb(all(a),b[i]) - a.begin();
        auto it2 = lb(all(c),b[i]) - c.begin();
        
        if(it1==a.size()) temp1 = n;
        else temp1 = it1;
        
        if(it2==c.size()) temp2 = 0;
        else{
            if(c[it2]==b[i]){
                auto it3 = lb(all(c),b[i]+1) - c.begin();
                temp2 = c.size()-it3;
            } else temp2 = c.size()-it2;
        }
        
        ans += (temp1 * temp2);
    }
    
    cout << ans;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 4524
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
#define sqr(x) ((x) * (x))
#ifdef LOCAL
#define dbg(as...) {\
    vector<string> _v; \
    std::stringstream _ss(#as);\
    string _cur, _loc;\
    while (getline(_ss, _cur, ',')) {\
        while (count(_cur.begin(), _cur.end(), '(') != count(_cur.begin(), _cur.end(), ')')) {\
            getline(_ss, _loc, ',');\
            _cur += "," + _loc;\
        }\
    _v.pb(_cur);\
    }\
    err(_v.begin(), as);\
}
#else
#define dbg(as...)
#endif

template<typename T>
void err(vector<string>::iterator it, T a) {
    cerr << it->substr((*it)[0] == ' ') << " = " << a << '\n';
}
template<typename T, typename...Ts>
void err(vector<string>::iterator it, T a, Ts...as) {
    cerr << it->substr((*it)[0] == ' ') << " = " << a << ", ";
    err(++it, as...);
}

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(10);
        #ifdef LOCAL
        srand(300); 
        #else
        srand(time(0));
        #endif
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;

const int MAXN = 1e5 + 15;
ll a[MAXN];
ll b[MAXN];
ll c[MAXN];
int p[MAXN];

void addprog(int l, int r, int start) {
    int len = r - l + 1;
    int fin = start - len + 1;
    c[l] += start;
    c[l + 1] -= start + 1;
    c[r + 1] -= fin - 1;
    c[r + 2] += fin;
}

void addconst(int l, int r, int cns) {
    c[l] += cns;
    c[l + 1] -= cns;
    c[r + 1] -= cns;
    c[r + 2] += cns;
}

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

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

    for (int i = 1; i < n; ++i) {
        if (p[i] > p[i - 1]) {
            int add = p[i] - p[i - 1];
            addconst(1, p[i - 1], add);
            addprog(p[i - 1] + 1, p[i], add);
            addconst(p[i] + 1, m, add);
        } else {
            int add = m - p[i - 1] + p[i];
            addprog(1, p[i], p[i]);
            addconst(p[i] + 1, p[i - 1], add);
            addprog(p[i - 1] + 1, m, add);
        }
    }

    for (int i = 1; i <= m + 2; ++i)
        b[i] = b[i - 1] + c[i];
    for (int i = 1; i <= m + 2; ++i)
        a[i] = a[i - 1] + b[i];

    cout << *std::min_element(a + 1, a + m + 1) << '\n';

    return 0;
}


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

int main() {
string s,t;
cin >> s >>t;

int X=0;
  int z = s.size();
  rep(i,z){
  if(s.at(i) != t.at(i)){
  X = X + 1;
  }
  }
cout << X << endl;

}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int x, y;
    cin >> x >> y;
    if(y >= 2*x && y <= 4*x && y % 2 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3516
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;

int n, x;
int a[100000];

signed main() {
	int i, j;
	
	cin >> n >> x;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int ans = 0;
	
	if (a[0] > x) {
		ans += a[0] - x;
		a[0] = x;
	}
	
	for (int i = 1; i < n; i++) {
		if (a[i-1] + a[i] > x) {
			ans += a[i-1] + a[i] - x;
			a[i] = x - a[i-1];
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k)
  {
    cout << s << endl;
  }else
  {
    for (int i = 0; i < k; i++)
    {
      cout << s[i];
    }
    cout << "..." << endl;
  }
  
  
  return 0;
  

}


Measured memory_bytes: 3592
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
//char a[200000],b[2000000],c[200000];
//char a[1000005],y[1000000],k[300];
int x[400000];

int main()
{
    long long int i,n,m,j,k,l,y,a,b;
    scanf("%lld %lld %lld",&y,&a,&b);
    j=0;
    //j+=y;
    j-=a;
    j+=b;
    if(j<=0)
    {
        printf("delicious\n");
    }else if(j<=y)
    {
        printf("safe\n");
    }else
    {
        printf("dangerous\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int K = sc.nextInt();
	int[] h = new int[N];
	for(int i = 0; i<N; i++) {
	    h[i] = sc.nextInt();
	}
	long[] cost = new long[N];

	cost[0] = 0;

	for(int i = 1; i<N; i++) {
	    long min = Long.MAX_VALUE;
	    for(int k = 1; k < K+1 && (i-k)>= 0; k++) {
		long c = cost[i-k] + Math.abs(h[i] - h[i-k]);
		if(min>c) min=c;
	    }
	    cost[i] = min;
	}
	System.out.println(cost[N-1]);


    }
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n, m, x;

	cin >> n >> m >> x;

	vector<ll> v(n, 0);

	REP(i, m) {
		ll a;
		cin >> a;
		v[a - 1] = 1;
	}

	ll ans = 0;

	REP(i, x) {
		ans += v[i];
	}

	ll sum = 0;

	FOR(i, x, n) {
		sum += v[i];
	}

	if (sum < ans) {
		ans = sum;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
const long long INF = 10000000000000;

long long d[300][300];
int V;

void warshall_floyd(){
    FOR(k,V){
        FOR(i,V){
            FOR(j,V){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int M;
	long long L;
    cin >> V >> M >> L;
    int s,t;
	long long u;
    FOR(i,300) FOR(j,300) d[i][j] = INF;
    FOR(i,M){
        cin >> s >> t >> u;
        s -= 1;
        t -= 1;
        d[s][t] = u;
        d[t][s] = u;
    }

    warshall_floyd();

    FOR(i,300){
        FOR(j,300){
            if (d[i][j] <= L) {d[i][j] = 1;}
            else {d[i][j] = INF;}
        }
    }

    warshall_floyd();

    int Q; cin >> Q;
    FOR(i,Q){
        cin >> s >> t;
        s -= 1;
        t -= 1;
        if (d[s][t] == INF){
            cout << -1 << endl;
        }else{
            cout << d[s][t]-1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

int main(){
  string S;
  cin >> S;
  string T;
  cin >> T;
  if(S.length() < T.length()){cout << "UNRESTORABLE" << endl; return 0;}
  for (int i = S.length() - T.length() ; i >= 0; i--) {
    bool can = true;
    for (int j = 0; j < T.length(); j++) {
      if(!(S[i+j] == T[j] || S[i+j] == '?'))can = false;
    }
    if(can){
      for (int l = 0; l < S.length(); l++) {
        if(i <= l && l < i+T.length())S[l] = T[l-i];
        else S[l] = (S[l] == '?' ? 'a' : S[l]);
      }cout << S << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;

int main(){
	ll n,x;
	cin>>n>>x;
	ll num[n+1],paty[n+1];
	num[0]=paty[0]=1;
	loop(i,1,n+1){
		num[i]=num[i-1]*2+3;
		paty[i]=paty[i-1]*2+1;
	}
	ll ans=0;
	for(int i=n;i>=1;i--){
		if(x==0)break;
		if(x>num[i-1]+1){
			ans+=paty[i-1];
			x-=num[i-1]+1;
			if(x==0)break;
			if(x==1){
				ans++;
				break;
			}
			if(x==num[i-1]+1||x==num[i-1]+2){
				ans+=paty[i-1]+1;
				break;
			}
			ans++;
			x--;
		}else{
			if(x==0||x==1)break;
			x--;
			if(x==num[i-1]){
				ans+=paty[i-1];
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

using namespace std;

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)||(a==5&&b==5&&c==7)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 256
from math import ceil,floor
n=int(input())
if n==1:
  print(0)
  exit()
a=[int(i) for i in input().split()]
for i in range(n):
  a[i]-=(i+1)
a.sort()

b1=a[ceil(n/2)]
b2=a[floor(n/2)]

def c1(x):
    return abs(x-b1)
def c2(x):
    return abs(x-b2)
print(min(sum(list(map(c1,a))),sum(list(map(c2,a)))))


Measured memory_bytes: 26832
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  int sum=0;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  sort(a.begin(),a.end());
  if(sum%10==0){
    for(i=0;a[i]%10==0&&i<n;i++);
    sum-=a[i];
    if(i==n)sum=0;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;

  int ans = 0;
  for(int i = 0; i < (int)str.size(); i++){
    char c = str[i];
    if(c == '1'){
      ans++;
    }
  } 
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
S = str(input())

l = list(S)
ans = l.count('R')*l.count('G')*l.count('B')
for i in range(N-2):
  a = l[i]
  for j in range(1, (N+1-i)//2):
    b, c = l[i+j], l[i+2*j]
    if (a!=b) and (b!=c) and (c!=a):
      ans -= 1
        
print(ans)


Measured memory_bytes: 9196
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

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


  vector<int> cu;
  int x=0;
  int need=0;
  for(int i=0;i<n;i++){
    if(a[i]<b[i]){
      x++;
      need+=b[i]-a[i];
    }else{
      cu.push_back(a[i]-b[i]);
    }
  }
  if(x==0){
    cout<<0<<endl;
    return 0;
  }

  sort(cu.begin(),cu.end(),greater<int>());
  int ans=x;
  int sum=0;
  bool f=false;
  for(int i=0;i<cu.size();i++){
    sum+=cu[i];
    ans++;
    if(sum>=need){
      f=true;
      break;
    }
  }
  if(f)cout<<ans<<endl;
  else cout<<-1<<endl;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,a,b,c,ct=0,flag,mx;
    string p,q,r;
    map<string,ll>mp;
    vector<string>v;
    cin>>n;
    mx=0;
    while(n--)
    {
        cin>>p;
        v.push_back(p);
        mp[p]++;
        c=mp[p];
        mx=max(c,mx);
    }
    sort(v.begin(),v.end());
    a=v.size();
    for(ll i=0;i<a;i++)
    {
        b=mp[v[i]];
        if(b==mx) {cout<<v[i]<<endl; mp[v[i]]=0;}
    }
}






Measured memory_bytes: 27120
<?php
define('N', 1000);

function trace(array $A, $n) {
  for ($i=0; $i<$n; $i++) {
    if($i > 0) printf(" ");
    printf("%s", $A[$i]);
  }
  printf("\n");
}

function to_numbers($str) {
  $num = preg_replace('/[^0-9]/', '', $str);
  return intval($num);
}

function swap(&$A, $i, $j) {
  $tmp = $A[$i];
  $A[$i] = $A[$j];
  $A[$j] = $tmp;
}

function bubleSort($A, $n) {
  $flag = 1;
  $B = array_map('to_numbers', $A);
  while($flag) {
    $flag = 0;
    for($j=$n-1; $j>0; $j--) {
      if($B[$j] < $B[$j-1]) {
        swap($A, $j, $j-1);
        swap($B, $j, $j-1);
        $flag = 1;
      }
    }
  }
  return $A;
}

function selectionSort($A, $n) {
  $B = array_map('to_numbers', $A);

  for($i=0; $i<$n; $i++) {
    $minj = $i;
    for($j=$i; $j<$n; $j++) {
      if($B[$j] < $B[$minj]) {
        $minj = $j;
      }
    }
    if ($i != $minj) {
      swap($B, $i, $minj);
      swap($A, $i, $minj);
    }
  }
  return $A;
}

function stable($A, $B, $n) {
  $before = to_numbers($B[0]);
  $before_num = to_numbers($B[0]);
  for($i=1; $i<$n; $i++) {
    $now = $B[$i];
    $now_num = to_numbers($now);
    //var_dump($now);
    if ($now_num == $before_num) {
      //var_dump(array_search($now, $A));
        //var_dump(array_search($before, $A));
      if (array_search($now, $A) < array_search($before, $A)) {
        echo "Not stable";
        return;
      }
    } else {
      $before = $now;
      $before_num = $now_num;
    }
  }
  echo "Stable";
}


$n = intval(trim(fgets(STDIN)));
$A = explode(' ', trim(fgets(STDIN)));

$R = bubleSort($A, $n);
trace($R, $n);
stable($A, $R, $n);
printf("\n");
$R = selectionSort($A, $n);
trace($R, $n);
stable($A, $R, $n);

?>



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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(), t.end(), greater<int>());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] set = new int[30];
        
        int w = sc.nextInt();
        int n = sc.nextInt();
        
        for (int i=0;i<w;i++) set[i] = i+1;
        for (int i=0;i<n;i++) {
            String[] str = sc.next().split(",");
            int a = Integer.parseInt(str[0]) - 1;
            int b = Integer.parseInt(str[1]) - 1;
            int temp = set[a];
            set[a] = set[b];
            set[b] = temp;
        }
        for (int i=0;i<w;i++) {
            System.out.println(set[i]);
        }
    }
}

Measured memory_bytes: 25764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int i = 1;
        int j = 2;
        while (true) {
            if (n <= i) break;
            
            i += j;
            j++;
        }
        
        System.out.println(j - 1);
    }
}


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

int main()
{
    string s,t;
    cin>>t>>s;

    int n=t.size();
    int ss=s.size();
    int rans=INT_MAX;
    for(int i=0;i<=n-ss;i++)
    {
        int cnt=0;
        for(int j=0;j<ss;j++)
        {
           // cout<<i+j<<" ";
            if(t[i+j]!=s[j])
            {
                cnt++;
            }
        }
        rans = min(cnt,rans);
        //cout<<endl;
    }
    cout<<rans<<endl;

}


Measured memory_bytes: 3628
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


a, b = rm()
print(math.ceil((a+b)/2))










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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

auto query(int pos) {
  cout << pos << "\n";
  std::flush(std::cout);
  string s;
  cin >> s;
  if (s == "Vacant") { exit(0); }
  return s;
}

auto opposite_sex(string s) {
  return s[0] == 'M' ? "Female" : "Male";
}

auto opposite_seat(string s, int size) {
  return (size / 2) % 2 == 0 ? s : opposite_sex(s);
}

int main() {
  int N; cin >> N;
  auto base = query(0);
  auto left = 0, right = N; // [left, right)
  rep(query_count, 19) {
    auto mid = (left + right) / 2;
    auto mid_result = query(mid);
    auto against_ = opposite_seat(base, right - left);
//    cout << "base: " << base << ", expected: " << against_ << ", mid_result: " << mid_result << "\n";
    if (against_ == mid_result) {
      left = mid + 1;
      base = opposite_sex(against_);
    }
    else {
      right = mid;
    }
  }
  assert(0);
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define x first
#define y second
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //assert(freopen("input.txt","r",stdin));
    //assert(freopen("output.txt","w",stdout));
    char c;
    cin>>c;
    if(c>=65&&c<=90)
        cout<<'A';
    else
        cout<<'a';
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int a[45];

int fib(int n){
  if(n==0||n==1) return a[n]=1;
  if(a[n]!=-1) return a[n];
  else return a[n]=fib(n-1)+fib(n-2);
}
int main(){
  int n,i;
  
  for(i=1;i<=44;i++) a[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int even[(int)1e5+9],odd[(int)1e5+9];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int x;
    cin>>x;
    int y[x+1];
    for (int i=1;i<=x;i++)
        cin>>y[i];
    for (int i=1;i<=x;i+=2)
        odd[y[i]]++;
    for (int i=2;i<=x;i+=2)
        even[y[i]]++;
    vector<pair<int,int>>e,o;
    for (int i=1;i<=(int)1e5+2;i++){
        if (even[i])
            e.push_back({even[i],i});
        if (odd[i])
            o.push_back({odd[i],i});
    }
            sort(e.begin(),e.end());
            sort(o.begin(),o.end());
            reverse(e.begin(),e.end());
            reverse(o.begin(),o.end());
    if (o[0].second!=e[0].second)
        cout<<x-(o[0].first+e[0].first)<<endl;
    else
    {
        if (e.size()<2)
            cout<<x-o[0].first;
        else if (o.size()<2)
            cout<<x-e[0].first;
        else
        {
            if (o[1].first>=e[1].first)
                cout<<x-(e[0].first+o[1].first);
            else
                cout<<x-(o[0].first+e[1].first);
        }
    }
}


Measured memory_bytes: 2428
#!/usr/local/bin/python3
# coding: utf-8
import math

hairu = input()
haitte = hairu.split(" ")
A = int(haitte[0])
B = int(haitte[1])
H = int(haitte[2])
M = int(haitte[3])
mKakudo = M/30*math.pi*1.0
hKakudo = H/6*math.pi + mKakudo/12
aida = abs(mKakudo - hKakudo)
nijou = A*A + B*B - 2*A*B*math.cos(aida)
print(math.sqrt(nijou))

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

#define pb push_back
#define ff first
#define ss second
#define SIZE 2001
#define INF 2e9 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"
#define usacoIN "buckets.in"
#define usacoOUT "buckets.out"

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;


int n, h, l, r, a[SIZE];

ll ans[200001];


int kol[2];
string s;


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);

    cin >> s;
    for(int i = 0; i < s.length(); i++)
    {
        kol[s[i] - 'A']++;
    }

    if(kol[0] && kol[1])
        cout << "Yes";
    else cout << "No";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,c;cin>>n>>c;
  int total=0,mine;
  for(int i=0;i<c;i++){
    int cake;cin>>cake;
    total+=cake;
  }
  mine=total/(n+1);
  if(total%(n+1)!=0) mine++;
  cout<<mine<<endl;
}


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

int a, b, c, d;

int main()
{
    cin >> a >> b >> c >> d;
    while(true)
    {
        c -= b;
        if(c <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        
        a -= d;
        if(a <= 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    
    return 0;
}

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

int main(){
	int n, a, b, p, q;
	scanf("%d%d%d%d", &n, &a, &b, &q);
	ll an = 0;
	f(i, 1, n){
		p = q;
		scanf("%d", &q);
		an += min((ll)b, (ll)(q - p) * a);
	}
	printf("%lld\n", an);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cstring>

const long long ma=1e18;

using namespace std;

int main()
{
    int x,y;
    scanf("%d %d",&x,&y);
    if(x%y!=0)
        printf("%d\n",x);
    else
        printf("-1\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;

const i64 MOD = 1e9+7;

// 素数列を作る
// N: 上限
// v: 出力先
void GetPrimes(int N, vector<int> &v) {
    v = vector<int>();
    int c = 1;
    while (c <= N) {
        c++;
        bool flag = true;
        int d = (int)sqrt(c);
        for (int i = 0; i < v.size(); i++) {
            if (c % v[i] == 0) {
                flag = false;
                break;
            }
            if (d < v[i])
                break;
        }
        if (flag)
            v.push_back(c);
    }
}

// 素因数分解を行う
// N: 対象
// p: 素数セット(GetPrimesで取得)
// m: 因数分解形式のマップ
void Factorize(int64_t N, const vector<int> &p, map<int, int> &m) {
    for (int i = 0; N != 1 && i < p.size(); i++) {
        while (N % p[i] == 0) {
            if (!m.count(p[i])) m[p[i]] = 0;
            N /= p[i];
            m[p[i]]++;
        }
    }
    if(N > 1) m[N] = 1;
}

// O(log a)
int64_t powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for (int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if (p & 1) value = (value * mul) % MOD;
    }
    return value;
}

int64_t invmod(int64_t x) {
    return powmod(x, MOD - 2);
}

struct Factorial {
    vector<int64_t> val;
    vector<int64_t> inv;
};

// O(N)
Factorial GetFact(int N) {
    N++;
    Factorial fact;
    fact.val = vector<int64_t>(N);
    fact.inv = vector<int64_t>(N);
    fact.val[0] = 1;
    for (int i = 1; i < N; i++) {
        fact.val[i] = int64_t(fact.val[i - 1] * i) % MOD;
    }
    fact.inv[0] = 1;
    fact.inv[N - 1] = powmod(fact.val[N - 1], MOD - 2);
    for (int i = N - 1; i > 0; i--) {
        fact.inv[i - 1] = int64_t(fact.inv[i] * i) % MOD;
    }
    return fact;
}

int64_t Permutation(int n, int m, const Factorial &f) {
    if (n < m || m < 0 || n < 0) return 0;
    return (f.val[n] * f.inv[n - m]) % MOD;
}

int64_t Combination(int n, int m, const Factorial &f) {
    if (n < m || m < 0 || n < 0) return 0;
    return ((f.val[n] * f.inv[m] % MOD) * f.inv[n - m]) % MOD;
}
int64_t Combination(vector<int> &n, const Factorial &f) {
    int sum = 0;
    for (auto i = n.begin(); i != n.end(); i++) {
        sum += *i;
    }
    int64_t retval = f.val[sum];
    for (auto i = n.begin(); i != n.end(); i++) {
        retval *= f.inv[*i];
        retval %= MOD;
    }
    return retval;
}

int main() {
    i64 N, M;
    cin >> N >> M;
    vector<int> p;
    map<int, int> m;
    Factorial f = GetFact(1e6);
    i64 ans = 1;
    GetPrimes(sqrt(M) + 100, p);
    Factorize(M, p, m);
    for(auto x : m) {
        int K = x.second;
        ans *= Combination(N + K - 1, K, f);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16000
import * as fs from "fs";

// inputで受け取り配列化する
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

const [N, K] = input[0].split(" ");

const prices = input[1].split(" ").map(Number);

prices.sort((a, b) => a - b);

let sum = 0;

for (let index = 0; index < Number(K); index++) {
  sum += prices[index];
}

console.log(sum);


Measured memory_bytes: 29744
local DBG = false
function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end
function dbgpr_t(tbl)
    if DBG then
        dbgpr(tbl)
        for i,v in ipairs(tbl) do
            io.write("[dbg]")
            print(i,v)
        end
    end
end
function swap(tbl, i, j)
    local oldj = tbl[j]
    tbl[j] = tbl[i]
    tbl[i] = oldj
end
function parse_table(N)
    local tbl = {}
    for i=1,N do
        table.insert(tbl, io.read("n"))
    end
    return tbl
end
function getline()
    local k = io.read("n")
    local tbl = parse_table(k)
    io.read("l")
    return tbl
end
function turn(hptbl)
    table.sort(hptbl)
    local minhp = hptbl[1]
    for i=2,#hptbl do
        hptbl[i] = hptbl[i] % minhp
    end
    next_tbl = {}
    for i=1,#hptbl do
        if hptbl[i] ~= 0 then
            table.insert(next_tbl, hptbl[i])
        end
    end
    table.sort(next_tbl)
    return next_tbl
end
function main()
    local n = io.read("n")
    io.read("l")
    local hptbl = parse_table(n)
    --dbgpr_t(hptbl)
    while #hptbl > 1 do
        hptbl = turn(hptbl)
        --dbgpr_t(hptbl)
    end
    print(hptbl[1])
end
main()


Measured memory_bytes: 4472
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B, C;
  cin >> A >> B >> C;
  if (A == B && A == C && A % 2 == 0) {
    cout << -1 << endl;
  } else {
    ll count = 0;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
      ll adda = (B + C) / 2;
      ll addb = (A + C) / 2;
      ll addc = (A + B) / 2;
      A = adda;
      B = addb;
      C = addc;
      // cout << adda << "," << addb << "," << addc << endl;
      // cout << A << "," << B << "," << C << endl;
      count++;
    }
    cout << count << endl;
  }
  return 0;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int answer = ((n-m) * 100 + m * 1900) * (int)Math.pow(2,m);
    System.out.println(answer);
    }
  }


Measured memory_bytes: 21844
use strict;
my $ans;
@_=split(/ /,<>);
foreach  ($_[1]..$_[0]+1){
    $ans += -($_ - 1) * $_ / 2 + (2 * $_[0] - $_ + 1) * $_ / 2 + 1;
    $ans %= 10**9+7;
}
print "$ans\n";


Measured memory_bytes: 4916
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  ll p = 0;
  for(auto&& e: s){
    p += (e-'0');
  }
  Pr(p%9==0);
}


Measured memory_bytes: 3824
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <string>
#include <queue>

using namespace std;

int d[101];
int f[101];
bool isUsed[101];
int cnt = 0;

void DFS(vector< vector<int> >& G, int vertex)
{
	d[vertex] = ++cnt;
	for (int i = 0; i < G[vertex].size(); ++i)
	{
		if (G[vertex][i] == 1 && isUsed[i] == false)
		{
			isUsed[i] = true;
			DFS(G, i);
		}
	}
	f[vertex] = ++cnt;
}

void solve()
{
	int n;
	cin >> n;
	vector< vector<int> > G(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		--u;
		for (int j = 0; j < k; ++j)
		{
			int v;
			cin >> v;
			--v;
			G[u][v] = 1;
		}
	}
	for (int i = 0; i < 101; ++i)
	{
		isUsed[i] = false;
	}
	for (int i = 0; i < n; ++i)
	{
		if (isUsed[i] == false)
		{
			isUsed[i] = true;
			DFS(G, i);
		}
	}
	for (int i = 0; i < n; ++i)
	{
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1256
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string s;
  cin>>s;
  size_t size=s.length();
  for(int i(size-2);i>=0;i--){
    if(i%2==0){
      int f(0);
      for(int j(0);j<i/2;j++){
        if(s[j]!=s[j+i/2])f=1;
      }
      if(f==0){
        cout<<i<<endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
4 9 2 3
---+/
/+---test
10 40 6 8
---+/
/+---test
314159265358979323 846264338327950288 419716939 937510582
---+/

void main(string[] args) {
  long A, B, C, D;
  readf(" %d %d %d %d ", &A, &B, &C, &D);

  const E = C*D / gcd(C, D);

  long ans = B/C - A/C + (A%C == 0);
  ans     += B/D - A/D + (A%D == 0);
  ans     -= B/E - A/E + (A%E == 0);
  (B-A-ans+1).writeln;
}


Measured memory_bytes: 256