akhauriyash/Code-Regression huggingface dataset:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    
    result = 0
    s = [0]
    for i in range(N):
        s.append(s[-1] + A[i])
        
    s.sort()
#    print(s)
    
    count = 1
    for i in range(N):
        if(s[i] == s[i+1]):
            count += 1
        else:
            result += count * (count -1 ) // 2
            count = 1
    result += count * (count -1 ) // 2
    print(result)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 26720
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    int N,Y;
    cin>>N>>Y;
    for(int x=0;N>=x;++x){
        for(int y=0;N>=y;++y){
            if(10000*x+5000*y+1000*(N-x-y)==Y&&N-x-y>=0){
                cout<<x<<" "<<y<<" "<<N-x-y<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 3596
import math

a, b, c = map(float, input().split())
c = math.radians(c)
h = b * math.sin(c)
s = a * h / 2
l = (b ** 2 + a ** 2 - 2 * a * b * math.cos(c)) ** 0.5 + a + b
print(s, l, h, sep='\n')


Measured memory_bytes: 5708
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int a,b;
		Scanner scan = new Scanner(System.in);
	     a = Integer.parseInt(scan.next());
	     b = Integer.parseInt(scan.next());
		if(a<b){
		System.out.println("a < b");
		}else if(a>b){
		System.out.println("a > b");
		}else{
	    System.out.println("a == b");
		}
		
	}
}

Measured memory_bytes: 26088
n=int(input())
x=input()
p=x.count("1")
Ma=[1]+[0]*(n-1)
Mb=[1]+[0]*(n-1)
for i in range(1,n):
  if p>1:
    Ma[i]=Ma[i-1]*2%(p-1)
  else:
    Ma[i]=0
    Ma[0]=0
  Mb[i]=Mb[i-1]*2%(p+1)
Sa=Sb=0
for i in range(n):
  if x[i]=="1":
    Sa+=Ma[n-1-i]
    Sb+=Mb[n-1-i]
for i in range(n):
  a=0
  if x[i]=="1":
    if p==1:
      s=0
    else:
      s=(Sa-Ma[n-1-i])%(p-1)
      a+=1
  else:
    s=(Sb+Mb[n-1-i])%(p+1)
    a+=1
  while(s>0):
    t=0
    r=s
    while(r>0):
      t+=r&1
      r//=2
    s%=t
    a+=1
  print(a)  

Measured memory_bytes: 26644
#include <stdio.h>
int dp[21][11][156];
int main(void)
{
    int n, k, s;
    dp[0][0][0]=1;
    for(n=1;n<=20;++n) {
        dp[n][0][0]=1;
        for(k=1;k<=10;++k) for(s=1;s<=155;++s)
            dp[n][k][s]=(n<=s?dp[n-1][k-1][s-n]:0)+dp[n-1][k][s];
    }
    while (scanf("%d%d%d", &n, &k, &s), n)
        printf("%d\n", dp[n][k][s]);
    return 0;
}

Measured memory_bytes: 732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

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() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    set<ll> s;
    map<ll,ll> m;
    rep(i,N){
        cin >> A[i];
        s.insert(A[i]);
        m[A[i]]++;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    ll ans=0;
    rep(i,N){
        if (m[A[i]]>0){
            m[A[i]]--;
            if (m[A[i]]==0){
                s.erase(A[i]);
            }
            ll j=1;
            while(1){
                if ((1<<j)>A[i]){
                    break;
                }
                j++;
            }
            ll k=(1<<j)-A[i];
            if (s.count(k)){
                ans++;
                m[k]--;
                if (m[k]==0){
                    s.erase(k);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 23680
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<cstdlib>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int maxn=1e5+5;
int n,k;
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll maxx=0;
    ll a1=a*c;
    ll b1=a*d;
    ll c1=b*c;
    ll d1=b*d;
    cout<<max(max(a1,b1),max(c1,d1))<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 3684
//#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define RANDOM srand(94385)
#define all(a) a.begin(), a.end()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)]);
#define enter putchar('\n')
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
using namespace std;

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

void debug_out() { cerr << '\n'; }
template<typename T, typename ...R>void debug_out(const T &f, const R &...r) {cerr << f << " ";debug_out(r...);}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);
inline ll read() {ll x = 0;int f = 0;char ch = getchar();while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();return x = f ? -x : x;}
inline void write(ll x) {if (x == 0) {putchar('0');return;}if (x < 0) {putchar('-');x = -x;}static char s[23];int l = 0;while (x != 0)s[l++] = x % 10 + 48, x /= 10;while (l)putchar(s[--l]);}
int lowbit(int x) { return x & (-x); }
template<class T>T big(const T &a1, const T &a2) { return a1 > a2 ? a1 : a2; }
template<typename T, typename ...R>T big(const T &f, const R &...r) { return big(f, big(r...)); }
template<class T>T sml(const T &a1, const T &a2) { return a1 < a2 ? a1 : a2; }
template<typename T, typename ...R>T sml(const T &f, const R &...r) { return sml(f, sml(r...)); }
template<class T, class U>inline void checkMin(T &x, U y) { if (y < x) x = y; }
template<class T, class U>inline void checkMax(T &x, U y) { if (y > x) x = y; }
template<class T, class U>inline bool ifMax(T &x, U y) {if (y > x) return x = y, true;return false;}
template<class T, class U>inline bool ifMin(T &x, U y) {if (y < x) return x = y, true;return false;}

const int M = 212345;// 2e5+5
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000000007;// 1e9+7

// HAVE FREE OPEN IN MAIN FUNCTION



void init() {
    ll t=read();
    write(t*(t-1)/2),enter;

}

void solve() {

}

int main() {
    init();

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int tax(int r,int p){
  return p*(100+r)/100;
}

int main(){
  int x,y,s;
  while(cin>>x>>y>>s&&(x>0&y>0&s>0)){
    int maxs = 0;
    for(int i=1;i<s;++i){
      for(int j=i;j<s;++j){
        if(tax(x,i)+tax(x,j) == s){
          maxs = max(maxs,tax(y,i)+tax(y,j));
        }
      }
    }
    cout<<maxs<<endl;
  }
  return 0;
}

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

int main()
{
  long double a, b;
  cin >> a >> b;

  long double ans = a*b;
  ans = floor(ans);
  cout << fixed << setprecision(0) << ans << endl;
  return 0;
}

Measured memory_bytes: 3792
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int r;
    cin >> r;
    cout << r * r * 3 << endl;
    return 0;
}

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

int main(void) {
	int i;
	int N;
	int x, y;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	x = N * 800;
	y = N / 15;
	y *= 200;

	printf("%d\n", x - y);

	return 0;
}


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

int main() {
  int N, A;
  cin >> N;
  cin >> A;
  int B = N/500;
    
  if (N-B*500 > A) {
    cout << "No" << endl;
  }
  else if (N-B*500 <= A){
    cout << "Yes" << endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
int main(void){
    ll N;cin>>N;
    ll p=1;
    REPS(i,N){
        p=(p*i)%MOD;
    }
    cout<<p<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;

int main() {
    int l;
    cin >> l;
    double a=l/3.0;
    cout << fixed << setprecision(30) << a*a*a << endl;
}

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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

int K, T;
int a[128];
int main(void){
	cin >> K >> T;
	for(int i=0;i<T;i++) cin >> a[i];
	
	sort(&a[0], &a[T]);
	cout << max(0, a[T-1]*2-1-K) << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

const ll MAX_N = 2e5+10;

int arr[MAX_N];

void Eratosthenes(ll n){
    for(ll i = 0; i < n; i++){
        arr[i] = 1;
    }
    for(ll i = 2; i < sqrt(n); i++){
        if(arr[i]){
            for(ll j = 0; i * (j + 2) < n; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
}

int main(int argc, char const *argv[])
{
    ll n;
    int a[MAX_N] = {0}, x[MAX_N] = {0};
    cin >> n;
    for (ll i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    Eratosthenes(n);

    vector<ll> vec;
    vector<vector<ll> > multi(n);
    bool tf = true;

    for (ll i = n; i > 0 && tf; --i) {
        if (i*2>n) {
            x[i] = a[i];
        }
        else {
            int sum = 0;
            for (int j = 2; j <= n/i; ++j) {
                //if (!arr[j]) continue;
                sum += x[j*i];
                sum %= 2;
            }
            if ((sum+1)%2==a[i]) {
                x[i] = 1;
            }
            else x[i] = 0;
        }
    }

    for (ll i = 1; i <= n; ++i) {
        if (x[i] == 1) {
            vec.emplace_back(i);
        }
    }

    if (tf) {
        cout << vec.size() << endl;
        for (int i = 0; i < vec.size(); ++i) {
            printf("%lld\n", vec[i]);
        }
    }
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 8820
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define ALL(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef pair<ut,ut> pr;
typedef vector<ut> VI;
typedef vector<pr> Vpr;
const LL INF = 1LL<<60;
const int SIZE=100;
int main(){
	int N,M;
	cin >> N >> M;
	int k,ans=0,x;
	REP(i,N){
		cout << "lst " << i<< endl; 
		cin >> k;
		ans+=k*(k-1);
		REP(i,k)
			cin >> x;
	}
	cout << "ans " << ans << endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
int main() {
	ll n;
	scanf("%lld", &n);
	int x, m;
	scanf("%d%d", &x, &m);
	vector<int> used(m);
	vector<ll> sum(m);
	int a = x;
	ll s = 0;
	bool proc = false;
	for (ll i = 1; i <= n;) {
		if (used[a] && !proc) {
			ll cycleSum = s - sum[a];
			int cycleLen = i - used[a];
			ll rounds = (n - i - 1) / cycleLen;
			s += rounds * cycleSum;
			i += rounds * cycleLen;
			proc = true;
			continue;
		}
		used[a] = i;
		sum[a] = s;
		s += a;
		a = (ll)a * a % m;
		++i;
	}
	printf("%lld\n", s);
}


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

int main(void) {
  int i, j, n, l;
  scanf("%d%d", &n, &l);
  char s[n][l + 10], t[l+ 10];
  for(i = 0; i < n; ++i) scanf("%s", s[i]);
  for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(strcmp(s[i], s[j]) > 0) strcpy(t, s[i]), strcpy(s[i], s[j]), strcpy(s[j], t);
  for(i = 0; i < n; ++i) printf("%s", s[i]);
  return 0;
}

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

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

struct Edge{
  int src,dst,cost;
  Edge(int src,int dst,int cost) : src(src), dst(dst), cost(cost) {;}
};

typedef vector<Edge> Edges;
const int inf = 1<<29;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x,int y) {
    x = root(x); y = root(y);
    if(x != y) {
      if(data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x,int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

bool operator<(const Edge &e,const Edge &f) {
  return (e.cost != f.cost) ? e.cost>f.cost : e.src<f.src;
}

int kruskal(vector<Edge> &g,int min,int nn) {
  priority_queue<Edge> Q;
  int i,j;
  const int n = g.size();
  rep(i,n)
    if(g[i].cost >= min) Q.push(g[i]);

  UnionFind uf(nn);
  int ee = Q.top().src,maxe = 0;
  while(!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    //cout<<nn<<" "<<maxe<<" "<<min<<endl;
    if(uf.findSet(e.src,e.dst)) continue;
    uf.unionSet(e.src,e.dst);
    maxe = max(maxe, e.cost);
  }
  if(uf.size(ee) < nn) return -1;
  return maxe - min;
}

int solve(vector<Edge> &g,vector<int> &w,int nn) {
  const int n = g.size();
  sort(w.begin(), w.end());
  int mi = w[0],ans = -1,i = 0;
  for(;;) {
    int a = kruskal(g,mi,nn);
    if(a == -1) return ans;
    if(ans == -1) ans = a;
    ans = min(ans, a);
    mi = w[++i];
    if(i == w.size()) return ans;
  }
}


int main() {
  int n,m,i,j,a,b,w;
  while(cin>>n>>m, n|m) {
    vector<Edge> g;
    vector<int> weight;
    rep(i,m) {
      cin>>a>>b>>w;
      a--; b--;
      weight.push_back(w);
      g.push_back(Edge(a,b,w));
    }

    if(m < (n-1)) cout<<-1<<endl;
    else cout<<solve(g,weight,n)<<endl;
  }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M;
  cin>>N>>M;
  vector<int>a(M),b(M);
  vector<vector<bool>>c(M,vector<bool>(N,false));
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    for(int j=0;j<b[i];j++){
      int C;cin>>C;C--;
      c[i][C]=true;
    }
  }

  vector<vector<ll>>dp(M+1,vector<ll>(pow(2,N),INF/2));
  dp[0][0]=0;
  //10^3
  for(int i=0;i<M;i++){ 
    //4*10^3
    for(int j=0;j<pow(2,N);j++){ 
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      int now=j;
      //12
      for(int k=0;k<N;k++){
        if(c[i][k]&&!((now>>k)&1))now+=pow(2,k);
      }
      dp[i+1][now]=min(dp[i+1][now],dp[i][j]+a[i]);
    }
  }
  ll ans=INF/2;
  for(int i=0;i<=M;i++){
    ans=min(ans,dp[i][pow(2,N)-1]);
  }
  if(ans==INF/2)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 34432
#include <stdio.h>
void insertionsort(int[], int);
void print(int[], int);
int main(int argc, char const *argv[])
{
	int i, j, a[100], n;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &a[i]);
	}
	insertionsort(a, n);	
	return 0;
}

void insertionsort(int a[], int n){
	int j, v, b[n], i;
	for(i=0;i<n;i++){
		b[i]=a[i];
	}
	for(i=0;i<n;i++){
		v=b[i];
		j=i-1;
		while(j>=0&&b[j]>v){
			b[j+1]=b[j];
			j--;
		}
		b[j+1]=v;
		print(b,n);
		if(i!=n-1){

		}
	}
}

void print(int b[],int n){
	int i;
	for(i=0;i<n;i++){
		if(i>0)printf(" ");
		printf("%d", b[i]);
	}
	printf("\n");
}	


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

int main(){
	
	char b;
	cin >> b;

	if (b == 'A') {
		cout << "T" << endl;
	}
	if (b == 'C') {
		cout << "G" << endl;
	}
	if (b == 'G') {
		cout << "C" << endl;
	}
	if (b == 'T') {
		cout << "A" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] c = new int[n];
        int[][] a = new int[n][m];
        for(int i=0; i<n; i++) {
            c[i] = Integer.parseInt(sc.next());
            for(int j=0; j<m; j++) {
                a[i][j] = Integer.parseInt(sc.next());
            }
        }
        
        
        int min = Integer.MAX_VALUE;
        for(int i=0; i<Math.pow(2, n); i++) {
            int[] asum = new int[m];
            int csum = 0;
            for(int j=0; j<n; j++) {
                if((1 & i >> j) == 1) {
                    csum += c[j];
                    for(int k=0; k<m; k++) {
                        asum[k] += a[j][k];
                    }
                }
            }
            
            boolean hantei = true;
            for(int k=0; k<m; k++) {
                if(asum[k] < x) {
                    hantei = false;
                    break;
                }
            }
            if(hantei) {
                if(min > csum) min = csum;
            }
        }
        
        if(min == Integer.MAX_VALUE) System.out.println(-1);
        else System.out.println(min);
    }
}

Measured memory_bytes: 37100
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }
};

int main(){
  int n; cin >> n;
  vi l(2*n); rep(i,2*n) cin >> l[i];

  sort(all(l));
  reverse(all(l));
  
  int j = 1;
  int ans = 0;
  rep(i,n) {
    ans += l[j];
    j += 2;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
i = 0
count = 0
while i < N-1:
    while S[i] == S[i+1]:
      i += 1
      if i == N-1:
        break
    if i == N-1:
      break
    count +=1
    i +=1
count +=1
print(count)


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


int main(void){
    int N=0;
    long K=0;
    int bin[50]={0};
    long long sum=0;
    long X=0;

    scanf("%d %ld",&N,&K);

    long A[N];

    for(int i=0;i<N;i++){
        A[i]=0;
        scanf("%ld",&A[i]);
        sum+=A[i];
        for(int j=0;j<50;j++){
            if((long)A[i]%2) bin[j]++;
            A[i]/=(long)2;
        }
    }

    for(int i=49;i>=0;i--){
        if(bin[i]<(int)(N+1)/2){
            if(X+(long)(pow(2,i))<=K){
                X+=(long)pow(2,i);
                sum+=(long long)pow(2,i)*(long long)(N-bin[i]*2);
            }
        }
    }
    
    printf("%lld",sum);
    

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);loop(i,0,n)cin>>var[i];
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull dint;

int main(void){
	init(string, s);

	outl(s == "Sunny" ? "Cloudy" : s == "Cloudy" ? "Rainy" : "Sunny");

	return 0;
}

Measured memory_bytes: 256
n=int(input())
if n==1:
    print(1)
    exit()
x=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append([a,b])
x.sort()
ans=float("inf")
for i in range(n-1):
    for j in range(i+1,n):
        p,q=x[j][0]-x[i][0],x[j][1]-x[i][1]
        cnt=0
        flg=[False for i in range(n)]
        for k in range(n):
            if flg[k]==False:
                flg[k]=True
                cnt+=1
                fl=True
                xx,yy=x[k][0],x[k][1]
                while fl:
                    nx,ny=xx+p,yy+q
                    if [nx,ny] in x:
                        a=x.index([nx,ny])
                        flg[a]=True
                        xx,yy=nx,ny
                    else:
                        fl=False
        if cnt<ans:
            ans=cnt
print(ans)

Measured memory_bytes: 74220
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front
#define yes cout << "YES" << '\n';
#define no cout << "NO" << '\n';
#define watch(x) cout << (#x) << " is " << (x) << endl
using namespace std;

int const MAXS = 1e5 + 5;

void solve(){
    int n;
    cin >> n;
    if(n%2 == 0 || n%5 == 0){
        cout << -1 << endl;
        return;
    }
    int ans = 7%n;
    for(int i = 1; i <= n; i++){
        if(ans == 0){
            cout << i << endl;
            return;
        }
        ans = (ans*10+7)%n;
    }
    cout << -1 << endl;
}

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

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int ans = 0;
		int sum = 0;
		for(int i=1; i<=n/2; i++){
			sum = i;
			for(int j=i+1; sum+j<=n; j++)sum+=j;
			if( sum==n )ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include<vector>
#include<iostream>
#include<cinttypes>
#include<algorithm>
#include<functional>
#include<queue>

using ui = std::uint32_t;
using si = std::int32_t;
using ull = std::uint64_t;



int main(){

	std::ios::sync_with_stdio( false );
	std::cin.tie( nullptr );

	ui n;
	std::cin >> n;

	std::vector< std::vector<ui> > links(n);

	for( ui i{}; i < n-1; ++i )
	{
		ui a, b;
		std::cin >> a >> b;
		--a; --b;

		links[a].emplace_back( b );
		links[b].emplace_back( a );

	}

	std::vector<ui> cn(n);
	for( auto&e : cn )
		std::cin >> e;

	std::sort( std::begin( cn ), std::end( cn ) );//, std::greater<>{} );
	
	std::queue<ui> leaves{};
	for( ui i{}; i < n; ++i ){

		if( links[i].size() != 1 )//size==1ならそのリンクは葉へのリンク
			continue;

		leaves.emplace( i );
		
//		pv[i] = cn[c_index++];
//		++c_index;
//		std::cout << i << " ";
	}//std::cout << "\n";

	
	std::vector<ui> pv( n, 0 );//1<=ci<=10^5なので0は無効値として使える.
	ui c_index = 0;
	ull ans{};
	while(! leaves.empty() )
	{
		const auto index_ = leaves.front(); leaves.pop();

		pv[index_] = cn[c_index++];

		if( c_index >= cn.size() )
			break;

		ans += pv[index_];
		for( const auto& v : links[index_] )
		{
//			std::cout << index_ << " " << v << " " << pv[v] << " => " << ans << "\n";
			{
				auto erase = []( auto&& v, auto value )
				{
					v.erase(
						std::remove( std::begin( v ), std::end( v ), value )
						, std::end( v )
					);
				};

				erase( links[v], index_ ); 
//				erase( links[index_], v );
//				*std::find(std::begin(links[index_]),std::end(links[index_]),v) = index_;
			}

			if ( links[v].size()==1 )
				leaves.emplace( v );

		}

	}


	{
		std::cout << ans << "\n";

		std::cout << pv[0];
		for( ui i{ 1 }; i < n; ++i )
			std::cout << " "<<pv[i];

		std::cout << "\n";
	}

	return 0;

}

Measured memory_bytes: 1024
N, X, M = [int(x) for x in input().split()]
s = [0] * (M+10)
s[1] = X
d = {X: 0}
tmp = X
for i in range(M):
    tmp = tmp * tmp % M
    if tmp == 0:
        print(s[i+1])
        exit()
    elif tmp in d:
        l, r = d[tmp], i+1
        sl = s[r] - s[l]
        loop = r-l
        ans = sl*((N-l)//loop) + s[l+(N-l)%loop]
        print(ans)
        exit()
    else:
        d[tmp] = i+1
        s[i+2] = s[i+1] + tmp
print(d)


Measured memory_bytes: 18016
#include <stdio.h>

int main(){
  char n1[10];
  char n2[10];
  char n3[10];


  scanf("%[^,]%*c", n1);
  scanf("%[^,]%*c", n2);
  scanf("%s", n3);
  printf("%s %s %s\n", n1, n2, n3);
  return 0;
}


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

vector<int> a;

bool solve (int sum, int target, int idx){
    if(sum == target) return 1;
    if(idx >= a.size()) return 0;
    return solve(sum, target, idx+1) || solve(sum+a[idx], target, idx+1);
}

int main(void){
    // Your code here!
    int n; cin >> n;
    a.resize(n);
    for(int i=0; i<n; i++) cin >> a[i];
    int q; cin >> q;
    for(int j=0; j<q; j++){
        int m; cin >> m;
        if(solve(0, m, 0)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include<iostream>

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

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

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

    int p[N];

    REP(i,N)cin >> p[i];

    int i = 0;
    int ans = 0;
    while(i < N){
        if(p[i] == i + 1){
            ans += 1;
            i += 2;
        }else{
            i++;
        }
    }

    cout << ans << endl;
}

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

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

  int ans = 0;
  for(int i = 0;i < n;i++){
    int tmp = a[i];
    while(1){
      if(tmp % 2 != 0){
        break;
      }
      ans++;
      tmp = tmp / 2;
    }
  }

  cout << ans << endl;
  return 0;
}


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

const int N_MAX = 100010;
int N, M, dp[N_MAX];
vector<int> E[N_MAX];

int dfs(int i){
    if (dp[i] != -1) return dp[i]; 

    int res = 0;
    for (int j = 0; j < E[i].size(); ++j){
        res = max(res, dfs(E[i][j]) + 1);
    }
    return dp[i] = res;
}

int main() {
	cin >> N >> M;
    for (int i = 1; i <= N; ++i){
        dp[i] = -1;
    }
    for (int j = 0; j < M; ++j){
        int x, y;
        cin >> x >> y;
        E[y].push_back(x);
    }

    int ans = 0;
    for (int i = 1; i <= N; ++i){
        ans = max(ans, dfs(i));
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13984
import math
from fractions import gcd
a,b,c,d = map(int,input().split())

c_num = b // c - (a-1) // c
d_num = b // d - (a-1) // d


def lcm(x, y):
    return (x * y) // gcd(x, y)
    
e = lcm(c,d)

e_num = b // e - (a-1) // e

print((b-a+1)-(c_num+d_num-e_num))

Measured memory_bytes: 63980
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#include<unordered_map>
#include<map>
#define int long long
using namespace std;

signed main() {
	int a, b, c, d, e;
	while (cin >> a, a) {
		cin >> b >> c >> d >> e;
		if ((b - c) / d + 1 < a) { puts("NA"); continue; }
		int s = 1, g = e+1;
		while (g - s > 1) {//????´\??°?¶????K??°????????\???????????????
			int k = (s + g) / 2;
			int f = c*k;
			if (f > b) { g = k; continue; }
			f = b-f;
			f = f / d;
			if (k + f >= a) {
				s = k;
			}
			else {
				g = k;
			}
		}
		cout << s<<" "<<(b - (s*c))/d << endl;
	}
}

Measured memory_bytes: 3000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int[] H = in.nextIntArray(N);
            
            int max = 0;
            int succ = 0;
            
            for (int i = 0; i < N - 1; ++i) {
                if (H[i] >= H[i + 1]) {
                    succ++;
                    max = Math.max(succ, max);
                } else {
                    succ = 0;
                }
            }
            
            out.println(max);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

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

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 40368
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;

//1!~N!を計算
vector<ll> Factorial(){
    vector<ll> v{1}; //0!
    ll f = 1;
    for(ll i = 1; i <= N; ++i){
        f *= i;
        f %= MOD;
        v.push_back(f);
    }
    return v;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void){
    
    scanf("%d", &N);
    auto fact = Factorial();
    
    vector<ll> inv(100001, 0);
    for(int i = 1; i <= N; i++){
		inv[i] = (inv[i - 1] + modinv(i, MOD)) % MOD;
	}
	
    ll ans = 0;
    for(int i = 1; i <= N; ++i){
        ll a; scanf("%lld", &a);
        ans += a * ((inv[i] + inv[N - i + 1]) - 1) % MOD;
        ans %= MOD;
    }
    
    printf("%lld\n", (ans * fact[N]) % MOD);
    
    return 0;
}

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

int main(){
	string N;
  	cin >> N;
  	int ans = 0;
  	for (int i=0; i<4; i++){
      	if(N[i] == '+'){
          ans++;
        }
      else {
        ans--;
      }
    }
        cout << ans << endl;
}

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

using namespace std;

const long long inf = (long long) 1e18;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, e, t;
  cin >> n >> e >> t;
  vector<int> x(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> x[i + 1];
  }          
  vector<int> first(n + 1); // first no wait from right to left
  for (int i = n, j = n; i >= 0; i--) {
    while (j > 0 && 2 * x[i] - 2 * x[j] <= t) {
      j--;
    }
    first[i] = j;
  }
  vector<long long> dp(n + 1, inf);
  dp[0] = 0;
  long long min_prefix = inf;
  for (int i = 1, j = 0; i <= n; i++) {
    while (j < first[i]) {
      min_prefix = min(min_prefix, dp[j] - 2 * x[j + 1]);
      j++;
    }
    dp[i] = min(t + dp[j], min_prefix + 2 * x[i]); 
  }
  cout << dp[n] + e << '\n';
  return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
class Main{
	 static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args)throws IOException{
    	   int n = Integer.parseInt(br.readLine());
    	//final int MAX =200000;
    	 /*  try {
     final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    	final int n = Integer.parseInt(reader.readLine());*/
    	//Scanner sc = new Scanner(System.in);
    	//int n = Integer.parseInt(sc.next());
    	//int n =sc.nextInt();
    	int[] R=new int[n];
    	
    	for(int i=0;i<n;i++){
    		// R[i]=Integer.parseInt(sc.next());
    		 R[i]=Integer.parseInt(br.readLine());
    	}
    	int maxv=-2000000000;
    			 
    	int minv=R[0];
    	for(int i=1;i<n;i++){
    		maxv=Math.max(maxv,R[i]-minv);
    		minv=Math.min(minv,R[i]);
    	}
    	System.out.println(maxv);
        /*reader.close();*/
/*        } catch (Exception e) {
            e.printStackTrace();
        }*/
    }
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> P(N);
  vector<int> Q(N);
  for(int i = 0; i < N; i++){
    cin >> P[i];
    Q[P[i] - 1] = i;
  }
  
  int cnt = 1;
  int max_cnt = 1;
  for(int i = 1; i < N; i++){
    if(Q[i - 1] < Q[i]) cnt++;
    else{
      max_cnt = max(cnt, max_cnt);
      cnt = 1;
    }
  }
  max_cnt = max(cnt, max_cnt);
  
  cout << N - max_cnt << endl;
  
  return 0;
}

Measured memory_bytes: 1792
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	X = LI()
	X = np.array(X)
	m = round(np.sum(X) / N)
	print(int(np.sum((X-m)**2)))

if __name__ == '__main__':
	main()

Measured memory_bytes: 12220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    cin >> s;
    int n = s.length();
    int res = INF;
    // s[0] == '0'
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        if(i % 2 == 0){
            if(s[i] == '1') ++cnt;
        }
        else{
            if(s[i] == '0') ++cnt;
        }
    }
    chmin(res, cnt);
    cnt = 0;
    // s[0] == '1'
    for(int i = 0; i < n; ++i){
        if(i % 2 == 0){
            if(s[i] == '0') ++cnt;
        }
        else{
            if(s[i] == '1') ++cnt;
        }
    }
    chmin(res, cnt);
    cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;
constexpr ll MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k;
  cin>>n>>k;
  ll ans = 0;
  FOR(i,k,n+2) {
    ll mn = ll(i) * (i-1) / 2;
    ll mx = i * (2 * n - i +1) / 2;
    ans += mx - mn + 1;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int gcd(int a,int b)
{
	int r,t;
	
	if(a<b){
			t=a;a=b;b=t;
		}
		while(b!=0){
			r=a%b;
			a=b;
			b=r;
		}
		
		return a;
}

int lcm(int a,int b)
{
	int i,t;
	
	if(a<b){
		t=a;a=b;b=t;
	}
	for(i=1;;i++){
		if((a*i)%b==0){
			return a*i;
		}
	}
}

int main()
{
	int a,b;
	
	while(scanf("%d %d",&a,&b)!=EOF){
		printf("%d %d\n",gcd(a,b),lcm(a,b));
	}
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main(){
    unsigned long long n, a, b;
    cin >> n >> a >> b;
    unsigned long long ans = n/(a+b)*a, rem = n % (a+b);
    ans += min(a, rem);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A,B,C=map(int,input().split())
ans=0
if A==B and B==C:
  if A%2==0:
    ans=-1
  else:
    ans=0
else:
  while True:
    if A%2==0 and B%2==0 and C%2==0:
      a,b,c=A//2,B//2,C//2
      A=b+c
      B=a+c
      C=a+b
      ans+=1
    else:
      break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, ans = 0;
    string s;
    cin >> s;
    rep(i, 0, 4){
        cout << s[i];
    }
    cout << " ";
    rep(i, 4, 12){
        cout << s[i];
    }
    cout << endl;

}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from collections import deque
sys.setrecursionlimit(10 ** 7)

def answer_is_X(X):
    mod = deque(sorted([i%X for i in A if i%X != 0]))
    answer = 0
    while mod:
        Amin = mod.popleft()
        answer += Amin
        while Amin > 0:
            # ポップできない場合
            if not mod:
                return False
            Amax = mod.pop()
            sub = X - Amax
            if sub <= Amin:
                Amin -= sub
            else:
                Amax += Amin
                mod.append(Amax)
                Amin = 0

    if answer <= K:
        return True
    else:
        return False

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N,K = map(int,input().split())
A = [int(i) for i in input().split()]

sumA_divisors = make_divisors(sum(A))

answer = 0
for i in sumA_divisors:
    if answer_is_X(i):
        answer = i

print(answer)

Measured memory_bytes: 43868
program sample
    implicit none
    integer(8) ::a, b,c,i,j,m,n,k,a1,b1,c1
    integer(8)::x,y(100)
    integer(8),allocatable::p(:)
    read(*,*) x,n
    if (n==0)then
        write(*,*)x
        stop
    end if
    allocate(p(n))

    read(*,*)p
    do i=1,100
        y(i)=1
    end do
    do i=1,n
        y(p(i))=0
    end do
    do i=0,100
        if (x-i==0)then
            write(*,*)x-i
            stop
        end if
        
        if (y(x-i)==1) then
            write(*,*)x-i
            stop
        end if
        if ( x+i==101)then
            write(*,*)x+i
            stop
        end if 
        if (y(x+i)==1) then
            write(*,*)x+i
            stop
        end if
    end do
    stop
    
    
end program sample
  



Measured memory_bytes: 2848
#include <bits/stdc++.h>
using namespace std;
long long int N, A[101010], B[101010], perm[101010];
bool cmp(int i, int j){
    return A[i] - B[i] > A[j] - B[j];
}
int main(){
    //freopen("test.in", "r+", stdin);
    long long int sA = 0, sB = 0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
        sA += A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
        sB+= B[i];
    }
    if(sB > sA)return cout<<-1<<endl, 0;

    long long int add = 0;
    long long int total_result = 0;

    for(int i=0;i<N;i++){
        if(A[i] < B[i])
            add += B[i] - A[i], total_result++;
    }


    for(int i=0;i<N;i++)
        perm[i] = i;

    sort(perm, perm + N, cmp);
    for(int i=0;i<N;i++){
        if(add <= 0)break;
        if(A[perm[i]] > B[perm[i]])
            add -= A[perm[i]] - B[perm[i]], total_result++;
    }
    cout<<total_result<<endl;
}


Measured memory_bytes: 2560
import math

def sieve_of_eratosthenes(n):
    prime=[]
    limit=math.sqrt(n)
    data=[i+1 for i in range(1,n)]
    while True:
        p=data[0]
        if limit<p:
            return prime+data
        prime.append(p)
        data=[e for e in data if e%p!=0]

n=55555
primes=sieve_of_eratosthenes(n)
k=(len(primes))
A=[]
for i in range(k):
    if primes[i]%5==1:
        A.append(primes[i])
N=int(input())
print(' '.join(map(str,A[:N])))

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

using namespace std;

const long long MOD = 1000000007;

long long fractorial_mod(long long n) {
    long long ret = 1;
    for (long long i = 2; i <= n; ++i) {
        ret *= i;
        ret %= MOD;
    }
    return ret;
}

void Main() {
    long long N, M;
    cin >> N >> M;

    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return;
    }

    long long ans = 0LL;
    if (N == M) {
        ans += fractorial_mod(N) * fractorial_mod(M);
        ans %= MOD;
        ans *= 2;
        ans %= MOD;
    }
    else {
        ans += fractorial_mod(N) * fractorial_mod(M);
        ans %= MOD;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from collections import*\n"
"class UnionFind():\n"
"    def __init__(self,size):\n"
"        self.table=[-1]*size\n"
"    def root(self,x):\n"
"        while self.table[x]>=0:\n"
"            x=self.table[x]\n"
"        return x\n"
"    def unite(self,x,y):\n"
"        s1=self.root(x)\n"
"        s2=self.root(y)\n"
"        if s1!=s2:\n"
"            if self.table[s1]>self.table[s2]:\n"
"                s1,s2=s2,s1\n"
"            self.table[s1]+=self.table[s2]\n"
"            self.table[s2]=s1\n"
"        return\n"
"    def same(self,x,y):\n"
"        return self.root(x)==self.root(y)\n"
"    def size(self,x):\n"
"        return -self.table[self.root(x)]\n"
"n,m,*t=map(int,open(0).read().split())\n"
"u=UnionFind(n+1)\n"
"f=defaultdict(list)\n"
"e=defaultdict(list)\n"
"for l,r,d in zip(t[::3],t[1::3],t[2::3]):\n"
"    u.unite(l,r)\n"
"    e[l].append((r,d))\n"
"for i in range(n+1):\n"
"    f[u.root(i)].append(i)\n"
"for t in f.values():\n"
"    if len(t)<3:continue\n"
"    outs=defaultdict(list)\n"
"    ins=defaultdict(int)\n"
"    for i in t:\n"
"        outs[i]=[j for j,v in e[i]]\n"
"        for j in outs[i]:\n"
"            ins[j]+=1\n"
"    q=deque(v1 for v1 in t if ins[v1]==0)\n"
"    res=[]\n"
"    while q:\n"
"        v1=q.popleft()\n"
"        res.append(v1)\n"
"        for v2 in outs[v1]:\n"
"            ins[v2]-=1\n"
"            if ins[v2]==0:\n"
"                q.append(v2)\n"
"    if not res:\n"
"        print('No')\n"
"        exit()\n"
"    c=defaultdict(int)\n"
"    for i in res:\n"
"        for j,v in e[i]:\n"
"            if c[j]and c[j]!=c[i]+v:\n"
"                print('No')\n"
"                exit()\n"
"            c[j]=c[i]+v\n"
"print('Yes')\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 89108
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<vector<lli> > vvi;
typedef vector<ii> vii;
 
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
 
const int mod = 1e9 +7;
lli n, arr[410][410], inp[410], presum[410];
 
inline lli min(lli a, lli b)
{
	if(a<b)	return a;
	else return b;
}
 
lli dp(int l, int r)
{
	if(arr[l][r]<1e18) return arr[l][r];
	else if(l==r) return arr[l][r]=0;
	else
	{
		for(int i=l; i<r; i++)
			arr[l][r] = min(dp(l,i)+dp(i+1,r)+presum[r]-presum[l-1], arr[l][r]);
		return arr[l][r];
	}
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	for(int i=0; i<410; i++)
		for(int j=0; j<410; j++)
			arr[i][j]=1e18;
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> inp[i], presum[i]=presum[i-1]+inp[i];
	cout << dp(1, n);
}

Measured memory_bytes: 4956