akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    ll X;
    cin >> X;
    FOR(i,-200,200) {
        FOR(j,-200,200) {
            ll a = i * i * i * i * i;
            ll b = j * j * j * j * j;
            if ((a-b) == X) {
                cout << i << " " << j << endl;
                return;
            }
        }
    }
}

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

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int> > > seq[13];
int main(){
	seq[0].push_back({});
	seq[2].push_back({{0, 1}});
	for(int i = 4; i <= 12; i += 2){
		for(int j = i - 1; j >= 1; j--){
			for(auto & e : seq[i - 2]){
				vector<pair<int,int> > nd;
				nd.push_back({j - 1, i - 1});
				for(auto & f : e){
					int x, y; tie(x, y) = f;
					nd.push_back({x + (x >= j - 1), y + (y >= j - 1)});
				}
				seq[i].push_back(nd);
			}
		}
	}
	int n, m;
	auto check = [&](vector<string> g){
		int hasMid = m & 1;
		vector<bool> used(m, false);
		vector<string> rev;
		for(int i = 0; i < m; i++){
			string up;
			for(int j = 0; j < n; j++) up.push_back(g[j][i]);
			rev.push_back(up);
		}
		for(int i = 0; i < m; i++){
			if(used[i]) continue;
			string c = rev[i];
			reverse(c.begin(), c.end());
			for(int j = i + 1; j < m; j++){
				if(used[j]) continue;
				if(c == rev[j]){
					used[i] = true;
					used[j] = true;
					break;
				}
			}
			if(!used[i]){
				if(c == rev[i]){
					if(hasMid){
						hasMid--;
						used[i] = true;
					} else {
						return;
					}
				} else {
					return;
				}
			}
		}
		cout << "YES" << endl;
		exit(0);
	};
	cin >> n >> m;
	vector<string> a(n), b, c;
	for(int i = 0; i < n; i++) cin >> a[i];
	int sz = n - (n&1);
	if(n & 1){
		for(int i = 0; i < n; i++){
			for(auto &e : seq[sz]){
				b = a; swap(b[i], b.back());
				c = a; c[n / 2] = b.back();
				int i = 0, j = n - 1;
				for(auto & f : e){
					c[i++] = b[f.first];
					c[j--] = b[f.second];
				}
				check(c);		
			}
		}
	} else {
		for(auto &e : seq[n]){
			c = a;
			int i = 0, j = n - 1;
			for(auto & f : e){
				c[i++] = a[f.first];
				c[j--] = a[f.second];
			}
			check(c);		
		}
	}
	cout << "NO" << endl;
	return 0;
}



Measured memory_bytes: 1280
#include<stdio.h>
int main(){
int a,b,c,d,e;
scanf("%d",&a);
for(b=1;b<=a;b++){
c=b/10;d=c/10;e=d/10;
if(b%10==3 || b%3==0 || b/10==3 || b/100==3 || b/1000==3){
printf(" %d",b);
}
else if(c%10==3 || c/10==3 || c/100==3){
printf(" %d",b);
}
else if(d%10==3 || d/10==3){
printf(" %d",b);
}
else if(e%10==3){
printf(" %d",b);
}
}
printf("\n");
return 0;
}


Measured memory_bytes: 2104
a = int(input())
lister = []
dicter = dict()
for i in range(0, 121):
    lister.append(i ** 5)
    lister.append(-i ** 5)
    dicter[i ** 5] = i
    dicter[- i ** 5] = -i

for i in range(1, 121):
    no = i ** 5 - a
    if no in lister:
        print(i, dicter[no])
        break

Measured memory_bytes: 79880
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]

w = [0, W]
h = [0, H]
for x, y, a in xya:
  if a == 1 and w[0] < x:
    w[0] = x
  elif a == 2 and w[1] > x:
    w[1] = x
  elif a == 3 and h[0] < y:
    h[0] = y
  elif a == 4 and h[1] > y:
    h[1] = y

if w[0] < w[1] and h[0] < h[1]:
  print(abs(w[0] - w[1]) * abs(h[0] - h[1]))
else: print(0)

Measured memory_bytes: 3064
def input_from_console():
    a, b = map(int, input().split())
    return a, b


def solve(a, b):
    k = (a + b)/2
    if k == int(k):
        return int(k)
    return "IMPOSSIBLE"


def main():
    a, b = input_from_console()
    print(solve(a, b))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 2940
// In The Name OF Allah
// Mehrkish Makuei
// Islamic Republic Of Iran

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

typedef long long ll;
#define Mehrkish ios::sync_with_stdio(false),		cin.tie(0),		cout.tie(0)
#define pb push_back

const int maxx = 2e5 + 19;
int n, m, a[maxx], c[maxx], b[maxx], ans, jvb, sum, z, l, x, y, k, minn = 99999999;
string s[119], t, w;
bool flag = true;
vector <ll> v;

void Input(){
	cin >> n >> m;;
}

void Solve(){
	if ( n >= 13 )
		ans = m;
	if ( n <= 12 and n >= 6 ) 
		ans = m / 2;
	if ( n < 6 )
		ans = 0;
	cout << ans << endl;
}


int main(){
	Mehrkish;
	Input(),	Solve();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int num, variety, cake[100], i, max= 0;

	scanf("%d%d", &num, &variety);

	for(i= 0; i< variety; i++)
	{
		scanf("%d", &cake[i]);
		if(cake[i]> max)
			max= cake[i];
	}

	if(max<= (num+ 1)/ 2)
		printf("0\n");
	else
		printf("%d\n", max* 2- num- 1);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if (B>=A*C) {
			System.out.println(C);
			return ;
		}
		System.out.println(B/A);
	}
}

Measured memory_bytes: 23892
////////////////////////////////////////////    _LeMur_
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 505;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n , k;
int a[N];

int neg[N] , pos[N];

bool check(int x){
    int sum = 0;
    for(int i=1;i<=n;i++){
        int md = a[i] % x;
        neg[i] = md;
        pos[i] = (x - neg[i]) % x;
        sum += neg[i];
    }
    if(sum % x)return false;
    sum /= x;
    sort(pos + 1 , pos + n + 1);
    int S = 0;
    if(sum){
        for(int i=1;i<=n;i++){
            if(pos[i] == 0)continue;
            S += pos[i];
            --sum;
            if(sum == 0)break;
        }
    }
    return (S <= k);
}

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n >> k;
    int sum = 0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        sum += a[i];
    }
    int res = 1;
    for(int i=1;i*i<=sum;i++){
        if(check(i)){
            res = max(res , i);
        }
        if(check(sum / i)){
            res = max(res , sum / i);
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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



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

    int N, M;
    cin >> N >> M;

    vector<vector<int>> Lamp;
    vector<vector<int>> Switch(N);

    int k, tmp_s;
    for(int i = 0; i < M; i++){
        cin >> k;
        vector<int> tmp_vs;

        for(int j = 0; j < k; j++){
            cin >> tmp_s;
            tmp_vs.push_back(tmp_s-1);
            Switch[tmp_s-1].push_back(i);
        }
        Lamp.push_back(tmp_vs);
    }

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

    int N_s = 1; //スイッチの個数
    for(int i = 0; i < N; i++){
        N_s = N_s * 2;
    }

    int ans = 0;

    for(int mask = 0; mask < N_s; mask++){

        vector<int> tmp_P(M);
        for(int j = 0; j < N; j++){
            if((mask >> j) & 1){ //j番目のスイッチがついていたら
                for(int l = 0; l < Switch[j].size(); l++){
                    tmp_P[Switch[j][l]] += 1;
                }
            }
        }

        bool tmp_ok = true;
        for(int j = 0; j < M; j++){
            if(tmp_P[j] % 2 != p[j] % 2){
                tmp_ok = false;
            }

        }

        if(tmp_ok){
            ans++;
        }

    }
    

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			int ten = 0;
			int out = 0;
			int run = 0;
			while (out < 3) {
				String line = scanner.next();
				if (line.equals("HIT")) {
					if (run == 3)
						ten++;
					else
						run++;
				} else if (line.equals("HOMERUN")) {
					ten += run + 1;
					run = 0;
				} else {
					out++;
				}
			}
			System.out.println(ten);
		}

	}

}

Measured memory_bytes: 17200
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
pii a[300010];
int heng[300010],shu[300010];
map<pii,int> ma;
int main()
{
	int i,j,k,n,m,x,y,z,t;
	scanf("%d%d%d",&n,&m,&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&a[i].fi,&a[i].se);
		heng[a[i].fi]++;
		shu[a[i].se]++;
		ma[a[i]]=1;
	}
	x=0;
	for(i=0;i<=300000;i++)
	{
		x=max(heng[i],x);
	}
	vector<int> he,sh;
	for(i=0;i<=300000;i++)
	{
		if(heng[i]==x)
		{
			he.push_back(i);
		}
	}
	y=0;
	for(i=0;i<=300000;i++)
	{
		y=max(shu[i],y);
	}
	for(i=0;i<=300000;i++)
	{
		if(shu[i]==y)
		{
			sh.push_back(i);
		}
	}
	for(i=0;i<he.size();i++)
	{
		for(j=0;j<sh.size();j++)
		{
			if(!ma.count(mp(he[i],sh[j])))
			{
				printf("%d",x+y);
				return 0;
			}
		}
	}
	printf("%d",x+y-1);
	return 0;
}


Measured memory_bytes: 30876
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

vi g[1000005];
int  n, m ,cnt = 0; 
bool vis[1000005];

void dfs(int u){
	if (vis[u]) return ; 
	cnt++;
	vis[u] = true;
	for (auto &it: g[u]){
		if (!vis[it]) dfs(it);
	}
}

signed main()
{
    cin >> n >> m ; 
    while (m--){
    	int a,b,c; cin >> a >> b >> c;
    	g[a].pb(b);
    	g[b].pb(a);
    }
    int ans=n;
    for (int i=1;i<=n;i++){
    	cnt = 0 ; 
    	dfs(i);
    	if (cnt>1) ans -= (cnt-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 33336
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{
    cin>>s1>>s2;
    s2.erase(s2.size()-1,1);
    if(s1==s2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3624
#include<stdio.h>
#define INFTY 2000000000
#define N 500001

int n,count;

void merge(int A[],int left,int mid,int right){
    int n1,n2,i,j,k;
    
    n1=mid-left;
    n2=right-mid;
    int L[n1+1],R[n2+1];
    for(i=0;i<n1+1;i++) L[i]=A[left+i];
    for(i=0;i<n2+1;i++) R[i]=A[mid+i];
    L[n1]=R[n2]=INFTY;
    i=j=0;
    for(k=left;k<right;k++){
        count++;
        if(L[i]<=R[j])A[k]=L[i++];
        else A[k]=R[j++];
    }
}

void mergeSort(int A[],int left,int right){
    int mid;
    
    if(left+1<right){
        mid=(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int main(){
  int i;
  int A[N];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
   
  return 0;
}



Measured memory_bytes: 5644
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll a,b; cin >> a >> b;
    if(abs(b-a) % 2 ==1){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (b+a)/2 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int H,n;
	cin >> H;
	cin >> n;
	int sum=0;
	for(int i=0;i<n;i++){
		int input;
		cin >> input;
		sum+=input;
	}
	if(sum>=H){
		cout << "Yes";
	}else{
		cout << "No";
	}
	return  0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

constexpr int MAX_N = 100010;

ll N, A, B;
std::vector<ll> h;
ll S = 0;

bool C( ll K )
{
  ll sum = 0;

  rep( i, N ) if( h[i]-K*B >= 0 )
    sum += (h[i]-K*B)/(A-B)+((h[i]-K*B)%(A-B)!=0?1:0);

  return sum <= K;
}

int main()
{
  scanf( "%lld%lld%lld", &N, &A, &B );
  rep( i, N )
  {
    ll x;
    scanf( "%lld", &x );
    h.push_back( x );
  }

  // (lb, ub]
  ll lb = 0, ub = 1e9;
  while( ub-lb > 1 )
  {
    ll mid = (lb+ub)/2;

    if( C(mid) )
      ub = mid;
    else
      lb = mid;
  }

  printf( "%lld\n", ub );

  return 0;
}

Measured memory_bytes: 1400
use std::io::*;
use std::str::FromStr;
use std::cmp::{ Ordering };

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: i64 = read();
    let l: i64 = read();

    let eaten = if l <= 0 && l + n - 1 >= 0 {
        0
    } else if l >= 0 {
        l
    } else {
        l + n - 1
    };

    let ret = n * (n - 1) / 2 + l * n - eaten;
    println!("{}", ret);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int n, x;
	cin >> n >> x;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		v[i] = abs(v[i] - x);
	}
	sort(v.begin(), v.end());
	set<int> s;
	for (int i = 1; i * i <= abs(v[0]); i++) {
		if (abs(v[0]) % i == 0) {
			s.insert(i);
			s.insert(abs(v[0] / i));
		}
	}
	int d = 1;
	for (auto itr = s.begin(); itr != s.end(); itr++) {
		bool f = true;
		for (int i = 0; i < n; i++) {
			if (v[i] % *itr != 0) {
				f = false;
				break;
			}
		}
		if (f) {
			d = *itr;
		}
	}
	cout << d << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int a[100100];
bool b[100100];

int main() {
    int N;
    cin >> N;
    rep(i, N)cin >> a[i];

    int cou = 0;
    int i = 0;
    while(true){
        if (b[a[i]] == true) {
            cout << -1 << endl;
            return 0;
        }
        if (a[i] == 2) {
            cou++;
            break;
        }
        b[a[i]] = true;
        cou++;
        i = a[i] - 1;
    }
    cout << cou << endl;
}

Measured memory_bytes: 768
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                             in(T &p){cin>>p;}
template<class T1,class T2>inline void                   in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T>inline void                             ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
template<class T>inline void                             outs(T p){for_each(all(p),out<decltype(p[0])>);}
string s;
long n;
inline void solve(void){
  in(s);
  n=s.size();
  for(int i=0;i<n-1;i++){
    if(s[i]=='C'){
      for(int j=i+1;j<n;j++){
        if(s[j]=='F'){
          cout<<"Yes"<<endl;
          return;
        }
      }
    }
  }
  cout<<"No"<<endl;
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define FORR(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define MAXIMIZE(a, b) (a) = max((a),(b))
#define MINIMIZE(a, b) (a) = min((a),(b))

using namespace std;
typedef pair<int,int> P;
typedef pair<P, P> PP;
typedef long long ll;
ll N;
int main() {
  cin >> N;
  for(ll h=1;h<=3500;++h) {
    for(ll n=1;n<=3500;++n) {
      long double w = (1.0 * N*n*h)/(1.0*4*h*n-N*(n+h));
      if (w<=0) continue;
      ll t=w;
      ll ws[]={t-1,t,t+1};
      FOR(it, ws) {
        ll checker = 4ll*h*n*(*it)-1ll*N*(n*h+h*(*it)+(*it)*n);
        if (checker==0) {
          printf("%lld %lld %lld\n", h,n,*it);
          return 0;
        }
      }
    }
  }

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
main(){
  int i,j,n,code;
  char cm[7],op,dict[262145];
  for(i=0,scanf("%d",&n),scanf("%s",cm);i<n;i++,scanf("%s",cm)){
    for(j=code=op=0;op!='\n';scanf("%c",&op))
      if(op=='A') code+=1*pow(4,j++);
      else if(op=='C') code+=2*pow(4,j++);
      else if(op=='G') code+=3*pow(4,j++);
      else if(op=='T') code+=4*pow(4,j++);
    if(cm[0]=='i') dict[code] = 1;
    if(cm[0]=='f') dict[code] ? printf("yes\n") : printf("no\n");
  }
  return 0;
}

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

def solve(H: int, A: int):
    if H % A == 0:
        print(H//A)
    else:
        print(H//A+1)

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

if __name__ == '__main__':
    main()


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

typedef struct point{
  double x;
  double y;
} point;

int koch(int, point, point);

int num;

int main(){
  point p1, p2;

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  scanf("%d" ,&num);

  printf("%.8f ",p1.x);
  printf("%.8f\n", p1.y);
  
  koch(num, p1, p2);

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

int koch(int n, point p1, point p2){

  point s, t, u;
  if(n == 0){
    return 0;
  }
  
  s.x = (2*p1.x + p2.x)/3;
  s.y = (2*p1.y + p2.y)/3;
  t.x = (p1.x + 2*p2.x)/3;
  t.y = (p1.y + 2*p2.y)/3;
  u.x = (t.x - s.x)*cos(M_PI/3) - (t.y - s.y) * sin(M_PI/3) + s.x;
  u.y = (t.x - s.x)*sin(M_PI/3) + (t.y - s.y) * cos(M_PI/3) + s.y;
  

  koch(n-1, p1, s);
  printf("%.8f ", s.x);
  printf("%.8f\n", s.y);
  
  koch(n-1, s, u);
  printf("%.8f ", u.x);
  printf("%.8f\n", u.y);
  
  koch(n-1, u, t);
  printf("%.8f ", t.x);
  printf("%.8f\n", t.y);
  
  koch(n-1, t, p2);

}



Measured memory_bytes: 2048
#include<iostream>

using namespace std;

int main(){
	int A,B,M;
	cin >> A >> B >> M;
	int a[A],b[B];
	struct {
		int* xp;
		int* yp;
		int c;
	} tickets[M];
	for(int i=0;i<A;i++){
		cin >> a[i];
	}
	for(int i=0;i<B;i++){
		cin >> b[i];
	}
	for(int i=0;i<M;i++){
		int x,y;
		cin >> x >> y >> tickets[i].c;
		tickets[i].xp=&a[x-1];
		tickets[i].yp=&b[y-1];
	}

	int amin=a[0];
	for(const auto& i : a){
		if(i<amin)amin=i;
	}

	int bmin=b[0];
	for(const auto& i : b){
		if(i<bmin)bmin=i;
	}

	int cmin=*tickets[0].xp + *tickets[0].yp - tickets[0].c;
	for(const auto& t : tickets){
		int value=*t.xp + *t.yp - t.c;
		if(value < cmin)cmin=value;
	}

	if(amin+bmin < cmin){
		cout << (amin+bmin) << endl;
	}else{
		cout << cmin << endl;
	}
	return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int c = sc.nextInt();

		char[] str = sc.next().toCharArray();
		//dp[i] : i日目にこなしている仕事の最大値
		int dp[] = new int[n];

		for(int i = 0; i < n; i++){
			//i日目に仕事が可能なら、累計数はi-(c + 1)日目より1大きくなる
			if(str[i] == 'o'){
				if(i <= c){
					dp[i] = 1;
				}
				else {
					dp[i] = dp[i - c - 1] + 1;
				}
			}
			//i日目に仕事ができないなら前日と累計数が変わらない
			else {
				if(i == 0){
					dp[i] = 0;
				}
				else {
					dp[i] = dp[i - 1];
				}
			}

		}

		//k日を上回る仕事をこなせるのなら、必ず働かなければならない日は存在しない
		if(dp[n - 1] > k){
			return;
		}

		//後で逆順で出力するのでスタックを採用
		Stack<Integer> stack = new Stack<Integer>();

//		int current;
		int count = 0;
//		int latestIndex = -1;
		int firstIndex = -1;
		for(int i = n - 1; i >= 0; i--){
//			current = dp[i];
//			System.out.println("i = "+i+ " number "+current);

			if(str[i] == 'o'){
				count++;
//				latestIndex = i;
				if(firstIndex == -1){
					firstIndex = i;
				}
			}

			if(i == 0 || dp[i - 1] != dp[i]){
				if(count == 1){
					stack.add(firstIndex + 1);
				}
				count = 0;
				if(i != 0){
//					i -= c;

					i = Math.min(i, firstIndex - c);
				}
				firstIndex = -1;

			}
		}

		while(!stack.isEmpty()){
			System.out.println(stack.pop());
		}
	}

}


Measured memory_bytes: 49952
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9 + 7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    //
    sort(A);
    //
    ll ans = 0;
    ans += A.back();
    A.pop_back();
    N -= 2;
    ll cnt = N / 2;
    rep(i, cnt)
    {
        ans += A.back() * 2;
        A.pop_back();
        N -= 2;
    }
    if (N != 0)
    {
        ans += A.back();
    }
    cout << ans;
    //
    return 0;
}

Measured memory_bytes: 4320
import math
n = int(input())
l = []
for i in range(n):
	t = input().split(" ")
	x = int(t[0])
	y = int(t[1])
	l.append([x, y])
d = 0
for i in range(n):
	for j in range(n):
		d += math.sqrt((l[i][0] - l[j][0]) * (l[i][0] - l[j][0]) + (l[i][1] - l[j][1]) *  (l[i][1] - l[j][1]))
a = d / n
print(a)

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;


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

	long long dp[61][2][2][2] = {};  // Zero initialization.
    dp[60][0][0][0] = 1;

    for(int i = 59; i >= 0; --i){
        int r = R >> i & 1;
        int l = L >> i & 1;

        rep(j, 2)rep(k, 2)rep(s, 2){
            rep(x, 2)rep(y, 2){

                if(y == 0 && x == 1) continue;

                int nj, nk, ns;
                nj = j, nk = k, ns = s;

                if(s == 0 && y == 1 && x == 0) continue;
                if(x == 1 && y == 1) ns = 1;

                if(k == 0 && r == 0 && y == 1) continue;
                if(r == 1 && y == 0) nk = 1;

                if(j == 0 && l == 1 && x == 0) continue;
                if(l == 0 && x == 1) nj = 1;

                dp[i][nj][nk][ns] += dp[i + 1][j][k][s];
                dp[i][nj][nk][ns] %= MOD;
            }
        }

    }

    long long ans = 0;
    rep(j, 2)rep(k, 2)rep(s, 2){
        ans += dp[0][j][k][s];
        ans %= MOD;
    }

    cout << ans << endl;
}


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

using namespace std;

int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);

        int t, n;

        cin >> n >> t;

        int sm_cost = 1001, sm_time = 1001, in_t, in_c;

        for(int i = 0; i < n; i++) {
                cin >> in_c >> in_t;
                if(in_t <= t) {
                        if(in_c < sm_cost) {
                                sm_cost = in_c;
                                sm_time = in_t;
                        } else if(in_c == sm_cost && in_t < sm_time) {
                                sm_cost = in_c;
                                sm_time = in_t;
                        }
                }

        }

        if(sm_cost == 1001) {
                cout << "TLE" << endl;
        } else {
                cout << sm_cost << endl;
        }
        return 0;
}


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

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

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

#define MAX_N 100
#define INF (1<<20)

int N;
int x[MAX_N], y[MAX_N], z[MAX_N], m[MAX_N];

bool input(){
  cin>>N;
  int a[3];
  REP(i, N) {
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);
    x[i] = a[0];
    y[i] = a[1];
    z[i] = a[2];
    m[i] = x[i]*y[i]*z[i];
  }
  return N!=0;
}

#define MAX_V 204
struct edge { int to, cap, cost, rev; };
int V; // ????????°
vector<edge> G[MAX_V]; // ??°???????????£??\???????????¨???
int dist[MAX_V]; // ???????????¢
int prevv[MAX_V], preve[MAX_V]; // ??´??????????????¨???
// from??????to??????????????????cap????????????cost???????????°?????????????????????
void add_edge(int from, int to, int cap, int cost) {
    G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
    G[to].push_back((edge){from, 0, -cost, (int)G[from].size() - 1});
}
// s??????t????????????f???????°??????¨???????±???????
// ??????????????´??????-1?????????
int min_cost_flow(int s, int t, int f) {

    int res = 0;
    while (f > 0) {
        // ???????????????????????????????????????s-t????????????????±???????
        fill(dist, dist + V, INF);
        dist[s] = 0;
        bool update = true;
        while (update) {
            update = false;
            for (int v = 0; v < V; v++) {
                if (dist[v] == INF) continue;
                for (int i = 0; i < G[v].size(); i++) {
                    edge &e = G[v][i];
                    if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        update = true;
                    }
                }
            }
        }
        if (dist[t] == INF) {
            // ????????\???????????????
            return -1;
        }
        // s-t????????????????????£??????????????????
        int d = f;
        for (int v = t; v != s; v = prevv[v]) {
            d = min(d, G[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * dist[t];
        for (int v = t; v != s; v = prevv[v]) {
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

void resetG(int ver){
  V = ver;
  REP(i,V)G[i].clear();//while(!G[i].empty()) G[i].pop_back();
//  REP(i,V){preve[i] = 0;prevv[i] = 0;}
}

void solve(){
 resetG(N * 2 + 2);
 REP(i,N){
   REP(j,N){
     if(i == j)
       continue;
     if(x[i] > x[j] && y[i] > y[j] && z[i] > z[j])
       add_edge(j,i + N, 1, 0);
   }
   add_edge(V-2, i, 1, 0);
   add_edge(i+N, V-1, 1, 0);
   add_edge(i, V-1, 1, m[i]);
 }
 cout<<min_cost_flow(V-2, V-1,N)<<endl;
}

int main(){
  cin.tie(0);

  while (input()){
    solve();
  }

  return 0;
}

Measured memory_bytes: 3288
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int n;
	ll z,w;
	ll a[2000];
	ll ans;
	
	cin>>n>>z>>w;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n>1)
	{
		ans = max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]));
	}else{
		ans = abs(a[0]-w);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main () {

   int n, i, j, k, v;
   int a[100] = {0};

   scanf("%d",&n);

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

   for(i = 1; i < n; i++){
      for(k = 0; k < n; k++){
         if(k == n-1){
            printf("%d\n",a[k]);
         } else {
            printf("%d ", a[k]);
         }
      }

      v = a[i];
      j = i -1;
      while(j >= 0 && a[j] > v){
         a[j+1] = a[j];
         j--;
      }

      a[j+1] = v;

   }
   for(k = 0; k < n; k++){
      if(k == n-1){
         printf("%d\n",a[k]);
      } else {
         printf("%d ", a[k]);
      }
   }

   return 0;

}


   

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

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

    ll kabu = 0, money = 1000, rest_money = 0;
    for (int i = 0; i < n; i++) {
        ll nex_kabu = kabu, nex_rest = rest_money;
        if ((kabu < money / a[i]) || (kabu == money / a[i] && rest_money < money % a[i])) {
            nex_kabu = money / a[i];
            nex_rest = money % a[i];
        }

        ll nex_money = max(money, kabu * a[i] + rest_money);
        kabu = nex_kabu;
        rest_money = nex_rest;
        money = nex_money;

        // cerr << kabu << " " << rest_money << " " << money << newl;
    }

    cout << money << newl;

    return 0;
}

Measured memory_bytes: 3608
// C - Vacation
#include <iostream>
#include <vector>
#define ll long long

using namespace std;

ll n;

// vector<ll> dp(3, vector<ll>(1000005, -1));
ll dp[1000005][3];

ll cost(vector<vector<ll> > &matrix, ll selected, ll day)
{
    if (dp[day][selected] != -1)
        return dp[day][selected];
    if (day == matrix.size())
        return matrix[day][selected];
    dp[day][selected] = max(cost(matrix, (selected + 1) % 3, day + 1) + matrix[day][selected], cost(matrix, (selected + 2) % 3, day + 1) + matrix[day][selected]);
    return dp[day][selected];
}

int main()
{
    cin >> n;
    vector<vector<ll> > matrix(n, vector<ll>(3, -1));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            dp[i][j] = -1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> matrix[i][j];
        }
    }
    cout << max(max(cost(matrix, 0, 0), cost(matrix, 1, 0)), cost(matrix, 2, 0));
} 

Measured memory_bytes: 17664
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        if (N % 2 == 0) {
            System.out.println(N/2-1);
        } else {
            System.out.println((N-1)/2);
        }
    }
}


Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main()
{
  int a,b,ans;
  cin>>a>>b;
  for(int i=1;i<1009;i++){
    if(i*2/25==a && i/10==b){ans=i; break;}
    if(i==1008)ans=-1;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
	int n, m, x, y;
  	cin>>n>>m>>x>>y;
  	bool s = n==2*x&&m==2*y;
  	cout << setprecision(12) << ((long double) n) * m / 2 << " " << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
unsigned gcd(unsigned a, unsigned b) {
	if (a < b) return gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
int main() {
	int K;
	int ans = 0;
	cin >> K;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				ans=ans+gcd(i, gcd(j, k));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    cout << N / 3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int N,i=0;
	scanf("%d", &N);
	if (N > i) {
			if (N > 18 && N < 20) {
				printf("Yes");
			}
			else if (N > 28 && N < 30) {
				printf("Yes");
			}
			else if (N > 38 && N < 40) {
				printf("Yes");
			}
			else if (N > 48 && N < 50) {
				printf("Yes");
			}
			else if (N > 58 && N < 60) {
				printf("Yes");
			}
			else if (N > 68 && N < 70) {
				printf("Yes");
			}
			else if (N > 78 && N < 80) {
				printf("Yes");
			}
			else if (N > 88) {
				printf("Yes");
			}else{
				printf("No");

	}


}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
vector < pair <int,int> > much;
int main()
{
    int n,k,i,z,a,b;
    scanf("%d%d",&n,&k);
    if(k>(n-1)*(n-2)/2)
    {
        printf("-1");
        return 0;
    }
    for(i=2; i<=n; i++)
        much.push_back({1,i});
    z=(n-1)*(n-2)/2;
    a=2;
    b=3;
    while(z>k)
    {
        much.push_back({a,b});
        b++;
        if(b>n)
            a++,b=a+1;
        z--;
    }
    printf("%d\n",much.size());
    for(i=0; i<much.size(); i++)
        printf("%d %d\n",much[i].first,much[i].second);

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int a;
	cin>>a;
	int b[a];
	float c=0;
	for(int i=0;i<a;i++){
		cin>>b[i];
		c+=b[i];
	}
	c/=2;
	for(int i=0;i<a;i++){
		c-=b[i];
		if(c<=0){
			if(abs(c)<abs(c+b[i]))
				cout<<abs(c)*2<<endl;
			else
				cout<<abs(c+b[i])*2<<endl;
			break;
		}
	}
	return 0;
}

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

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,a,b;
  cin>>n>>a>>b;
  int x=0,y=0,z=0;
  rep(i,n)
  {
    int t;cin>>t;
    if(t<=a)x++;
    else if(t<=b)y++;
    else z++;
  }
  cout<<min({x,y,z})<<endl;

  return 0;

}


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

int main() 
{
  int N;
  cin >> N;
  vector<int> a(N);
  int m = 0;
  for (int i=0;i<N;i++)
      cin >> a[i];
  
  for (int i=0;i<N;i++)
    {
      //      cout << a[i] << endl;
      //cout << a[a[i]-1]<<endl;
      
      if (a[a[i]-1]==i+1)
	m++;
    }
  cout << m/2 << endl;
}


Measured memory_bytes: 768
# coding: utf-8
# Your code here!

N, K, Q = map(int,input().split())
L = [0]*N
for i in range(Q):
    a = int(input())
    L[a-1] += 1

for i in range(N):
    if Q - L[i] < K:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4680
MOD = 10 ** 9 + 7
N = int(input())
C = list(map(int, input().split()))
C.sort()

if N == 1:
    print (2 * C[0] % MOD)
    exit()


lst = [0] * (N + 3)
lst[0] = 1
for i in range(1, N + 3):
    lst[i] = (lst[i - 1] * 2) % MOD


ANS = 0
for i, c in enumerate(C):
    ANS += c * (N + 1 - i)

ANS *= lst[N - 2]
ANS %= MOD
ANS *= lst[N] 
print (ANS % MOD)

Measured memory_bytes: 25508
input_line = []

while line = gets
  input_line << line.chomp
end

n = input_line.shift.to_i
s = input_line.shift.chomp.split(" ")
list = []
n.times do |i|
  list << s[i].to_i
end

puts "#{list.min} #{list.max} #{list.inject(:+)}"

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


int main()
{
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  rep(i, N) cin >> p[i];
  vector<double> q(N);
  rep(i, N)
  {
    long long sum = 0;
    for (int j = 1; j < p[i] + 1; j++)
    {
      sum += j;
    }
    q[i] = sum / p[i];
  }

  int s = 0;
  int g = K;
  double ans = 0;
  rep(i, K)
  {
    ans += q[i];
  }

  double pre_ans = ans;

  while (g < N + 1)
  {
    pre_ans = pre_ans - q[s] + q[g];
    if (ans < pre_ans)
    {
      ans = pre_ans;
    }
    s++;
    g++;
  }

  cout << setprecision(15);
  cout << ans << endl;
}


Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    for u in range(n-1):
        ans=[]
        for v in range(u+1,n):
            w=u^v
            for i in range(10):
                if((w>>i)&1):
                    ans.append(i+1)
                    break
        print(*ans)
resolve()

Measured memory_bytes: 48220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=1000;

ll N,K;

ll d_sum(ll n){
  ll res=0;
  while(n>0){
    res+=n%10;
    n/=10;
  }
  return res;
}

double sn(ll n){
  return (double)(n)/d_sum(n);
}

int main(){
  cin>>K;
  ll b=1;
  vector<ll> candidate;
  for(ll i=0;i<15;i++){
    for(ll j=1;j<1001;j++){
      candidate.emplace_back(b*(j+1)-1);
    }
    b*=10;
  }
  sort(candidate.begin(), candidate.end());
  candidate.erase(unique(candidate.begin(), candidate.end()), candidate.end());
  for(ll i=0;i<candidate.size();i++){
    for(ll j=i+1;j<candidate.size();j++){
      if(sn(candidate[i])>sn(candidate[j])){
        candidate.erase(candidate.begin()+i);
        i--;
        break;
      }
    }
  }

  for(ll i=0;i<K;i++){
    cout<<candidate[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;

void solve(int a, int b){
    if(a == 1){
        printf("3800\n");
    }else{
        printf("%d\n", int(int(pow(2.0, double(b))) * (1900*b + 100*(a-b))));
    }
}

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    solve(a, b);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI2(a,b);
    print((a+b+1)/2);
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<string>s(n);
    for(int i=0;i<n;++i){cin>>s[i];}
    sort(s.begin(),s.end());
    string a=s[0];
    int cnt=1,cntm=0;
    vector<pair<int,string>>ans;
    for(int i=1;i<n;++i){
        if(a!=s[i]){
            ans.push_back(make_pair(cnt,a));
            a=s[i];
            if(cnt>cntm)cntm=cnt;
            cnt=1;}
        else{cnt++;}
        if(i==n-1){
            ans.push_back(make_pair(cnt,a));
            if(cnt>cntm)cntm=cnt;
        }
    }
    for(int i=0;i<ans.size();++i){
        if(ans[i].first==cntm)cout<<ans[i].second<<endl;
    }
}

Measured memory_bytes: 18292
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
int a[114514];
signed main(){
	ic(n) sc(s)
	int ans=0;
	rep(0,i,n-1)if(s[i]!=s[i+1])ans++;
	c(ans+1)
}	

Measured memory_bytes: 512
def is_sqrt(m,n):
    return m**2 <= n < (m+1)**2

def isqrt(n):
    low = 0
    high = n
    m = (low + high)//2

    while not is_sqrt(m,n):
        if m**2 < n: #too small! must be in [m+1,high]
            low = m+1
        else: #too big! must be in [low, m-1]
            high = m - 1
        m = (low + high) // 2
    return m

def is_square(n):
    return n == (isqrt(n))**2

n,d = map(int,raw_input().split())
x = []
for a in range(n):
  x.append(map(int,raw_input().split()))
ans = 0
for a in range(n):
  for b in range(a+1,n):
    q = 0
    for c in range(d):
      q += (x[a][c] - x[b][c])**2
    if is_square(q) == True:ans += 1
print ans

Measured memory_bytes: 2696
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int k = stdIn.nextInt();
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		for(int i = a; i <=b; i++) {
			if(i % k == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
		
		
	}

}


Measured memory_bytes: 35764