akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] s = stdR.readLine().split(" ");
        int W = Integer.parseInt(s[0]);
        int H = Integer.parseInt(s[1]);
        int x = Integer.parseInt(s[2]);
        int y = Integer.parseInt(s[3]);
        double d = (long)W * H / 2d;
        if(x == W / 2d && y == H / 2d) {
            System.out.println(d+" "+1);
        }else {
            System.out.println(d+" "+0);
        }
    }
}


Measured memory_bytes: 21204
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int a,b;
  int c[1000];
  cin>>a>>b;
  int sum=0;
  for(int i=0;i<b;i++){
    cin>>c[i];
    sum=max(sum,c[i]);
  }
  if(b!=1)
    cout<<max(sum-(a-sum)-1,0);
  else
    cout<<a-1<<endl;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
w0,v=map(int,input().split())
goods=[[v],[],[],[]]
for i in range(N-1):
    w,v=map(int,input().split())
    goods[w-w0].append(v)
val=[]
for x in range(4):
    goods[x].sort(reverse=True)
    valx=[0]*(len(goods[x])+1)
    for k in range(len(goods[x])):
        valx[k+1]=valx[k]+goods[x][k]
    val.append(valx)
ans=0
for i in range(len(goods[0])+1):
    if w0*i>W:
        break
    for j in range(len(goods[1])+1):
        if w0*(i+j)+j>W:
            break
        for k in range(len(goods[2])+1):
            if w0*(i+j+k)+j+2*k>W:
                break
            for l in range(len(goods[3])+1):
                if w0*(i+j+k+l)+j+2*k+3*l>W:
                    break
                ans=max(ans,val[0][i]+val[1][j]+val[2][k]+val[3][l])
print(ans)

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int x;
  cin >> x;
  
  cout << 8-(x-400)/200 << endl;
  
  return 0;
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

// mod. m での a の逆元 a^{-1} を計算する
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;
}

long long int combination_mod(long long int a,long long int b){
    long long int ans=1;
    b=min(b,a-b);
    for(int i=0;i<b;i++){
        ans*=a-b+i+1;
        ans%=MOD;
        ans*=modinv(i+1,MOD);
        ans%=MOD;
    }
    return ans;
}

int main(){
    LL(n,a,b);
    //debug(modpow(2,n,(ll)MOD),combination_mod(n,a),combination_mod(n,b));
    ll ans=modpow(2,n,(ll)MOD)-combination_mod(n,a)-combination_mod(n,b)-1;
    ans%=MOD;
    if(ans<0)ans+=MOD;
    out(ans);
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
const int mod=1e9+7;
using namespace std;
const int num=200001;
vector<int> g[num];
vector<bool> vis(num, 1);
int dfs(int x){
    //cout<<" d "<<i<<endl;
    vis[x]=0;
    int c=1;
    for(int i=0; i< g[x].size(); i++){
        if(vis[g[x][i]]){
            c +=dfs(g[x][i]);
        }
    }
    //cout<<c<<" d "<<x<<endl;
    return c;

}
signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   //freopen("input.txt", "r", stdin);
    int n,m; cin>>n>>m;
    //initial(n);
    map<int, set<int>> mp;
    int x,y;
    for(int i=0; i<m; i++){
        cin>>x>>y;
        
        if(x > y)
        mp[x].insert(y);
        else
        mp[y].insert(x);
        
    }
    for(auto i: mp){
        for(int j: i.second){
            g[i.first].push_back(j);
            g[j].push_back(i.first);
        }
    }
    /*for(int i=1; i<=5; i++){
        cout<<i<<" -> ";
        for(int j=0; j < g[i].size(); j++) cout<<g[i][j]<<" "; cout<<endl;
    }*/
    for(int i=1; i <=n; i++){

    }
    int c=0;
//vector<int> b(n+1, 0);
    for(int i=1; i<=n; i++){
        if(vis[i]){
            //cout<<i<<endl;
            c = max(c , dfs(i));
        }
    }
     //for(int i=1; i<=n; i++) cout<<b[i]<<" "; cout<<endl;
    cout<<c<<endl;
}

Measured memory_bytes: 52040
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 10 21:39:20 JST 2020
 **/

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

void no() {
    std::cout << "No" << std::endl;
    exit(0);
}

using pii = std::pair<Int, Int>;
signed main() {
    Int n;
    std::cin >> n;
    Int total = 0;
    std::vector<std::vector<pii>> ps(2);
    std::vector<Int> X(2);
    REP(i, n) {
        std::string s;
        std::cin >> s;
        Int mi = 1e9, acc = 0;
        for (char c : s) {
            acc += c == '(' ? 1 : -1;
            chmin(mi, acc);
        }
        total += acc;
        REP(t, 2) {
            if (mi >= 0) {
                X[t] += acc;
            } else if (acc >= 0) {
                ps[t].push_back({mi, acc});
            }
            mi -= acc;
            acc = -acc;
        }
    }
    if (total != 0) no();
    REP(t, 2) {
        std::sort(ps[t].rbegin(), ps[t].rend());
        for (auto& p : ps[t]) {
            if (X[t] + p.first < 0) no();
            X[t] += p.second;
        }
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 10172
#include<bits/stdc++.h>
 
using namespace std ;
 
typedef double D ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned int ui ;
typedef unsigned long long ull ;
 
# define F first
# define S second
# define R return
# define C continue 
# define pb push_back 
# define pf push_front
# define mp make_pair
 
# define vi vector <int>
# define vb vector <bool>
# define vll vector <ll>
# define vs vector <string>
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
 
# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >
# define vvpii vector < vector < pii > >
 
# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp
 
# define Fi(i,L,R) for (int i = L ; i <= R ; i++)
# define Fd(i,R,L) for (int i = R ; i >= L ; i--)

# define FAST ios_base :: sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0)
 
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))
 
const ll MOD = 1e9 + 7 ;
const int infi =  INT_MAX ;
const ll infll =  LLONG_MAX ;
const ld PI = 3.1415926535897932384626 ;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve (int test_case)
{
	int r ;
	cin >> r ;
	cout << fixed << setprecision(20) << ld(2) * ld(r) * PI ;
}
 
int main()
{
	//freopen ("input.txt","r",stdin) ;
	//freopen ("output.txt","w",stdout) ;
	
	FAST ;
	int tc = 1 ;
//	cin >> tc ;
	while (tc--) 
	    solve (tc) ;
	return 0 ;
}

Measured memory_bytes: 3804
using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long sum = 0;

            for (int i = 1; i <= n; i++)
            {
                if (i % 3 == 0 && i % 5 == 0)
                    continue;
                else if (i % 3 == 0)
                    continue;
                else if (i % 5 == 0)
                    continue;
                else
                    sum += i;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 17624
sx, sy, tx, ty = map(int, raw_input().split())

gx = ''
gy = ''
bx = ''
by = ''

for i in range(0, tx-sx):
	gx = gx + 'R'
	bx = bx + 'L'
for i in range(0, ty-sy):
	gy = gy + 'U'
	by = by + 'D'

print gx + gy + bx + by + 'D' + gx + 'RU' + gy + 'LU' + bx + 'LD' + by + 'R'

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

int main(void){
  int n;
  long a[5000];
  long long max, tmp;

  while(cin >> n && n != 0){
    for(int i = 0; i < n; i++) cin >> a[i];
    max = a[0]; tmp = 0;

    for(int i = 0; i < n; i++){
      for(int j = i; j < n; j++){
        tmp += a[j];
        if(max < tmp) max = tmp;
      }
      tmp = 0;
    }
    cout << max << endl;
  }
  return 0;
}

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



int main(){
	long long n,a,b,aa=-1e9,bb;
	cin >> n;
	for(long long i=0;i<n;i++){
		cin >> a >> b;
		if(aa<a){
			aa=a;
			bb=b;
		}
	}
	for(long long i=1;;i++){
		if(bb-i==0){
			cout << aa+i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

bool p[100001];
bool q[100001];
int main()
{
	ll maxV = 100000;
	rep(i, 0, maxV)p[i] = true;
	p[0] = false;
	p[1] = false;

	for (int i = 2; i*i <= maxV; i++) {
		if (!p[i])continue;
		for (int j = 2; i*j <= maxV; j++) {
			if (i*j <= maxV) {
				p[i*j] = false;
			}
		}
	}

	rep(i, 0, maxV) {
		q[i] = p[i];
	}

	rep(i, 0, maxV) {
		if (p[i] && p[(i + 1) / 2]) {
			q[i] = true;
		}
		else {
			q[i] = false;
		}
	}
	ll s[100001] = {};
	rep(i, 1, maxV) {
		s[i] += s[i - 1] + (q[i] ? 1 : 0);
	}

	ll Q; cin >> Q;
	rep(i, 0, Q) {
		ll l, r; cin >> l >> r;
		cout << s[r] - s[l - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A[3];cin>>A[0]>>A[1]>>A[2];
  cout << max({A[0],A[1],A[2]})-min({A[0],A[1],A[2]})<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define loop(i) for(int lp = 0; (lp) < (i); (lp) ++)

using namespace std;

int main() {
  int m, _A, year, n;
  cin >> m;
  loop(m) {
    cin >> _A >> year >> n;

    
    int ans = 0;
    for(int i = 0; i < n; i ++) {
      int A = _A;
      int B = 0;
      int C = 0;
      int type, t;
      double r;
      cin >> type >> r >> t;
      
      loop(year) {
	if(type) {
	  B = A*r;
	  A = A+B-t;
       	}
	else {
	  B = A*r;
	  A = A-t;
	  C += B;	
	}
      }

      ans = (ans>(A+C))?ans:(A+C);
    }

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

Measured memory_bytes: 1232
import java.util.Scanner;
import java.io.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		String str;
		String a, b;
		int m;
		int h;
		while(true)
		{
			str = sc.next();
			if(str.equals("-"))
			{
				break;
			}
			m = sc.nextInt();
			for (int i = 0; i < m; i++)
			{
				h = sc.nextInt();
				a = str.substring(0, h);
				b = str.substring(h, str.length());
				str = b + a;
			}
			System.out.println(str);
		}
		sc.close();
	}
}


Measured memory_bytes: 26256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N=int(input())
i = list(map(int, input().split()))
c=0

for k in range(0,N):
  if i[k]%2==0:
    if (i[k]%3!=0) and (i[k]%5!=0):
      c=c+1

if c==0:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
#include<cmath>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<stack>
#include<vector>
#include<string.h>
#include<string>
#include<iomanip>
#include <sstream>
#include<map>
#include<complex>
#include<set>
using namespace std;
#define rep(i,t,n)  for(ll i =(t);i<=(n);++i)
#define per(i,n,t)  for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define Decimal fixed<<setprecision(20)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 5;
typedef double db;
const db pi = acos(-1.);
ll n, k;

int d[maxn];
int main() {
	FAST_IO;

	cin >> n;
	rep(i, 1, n) {
		cin >> d[i];
	}
	sort(d + 1, d + 1 + n);
	int ans = 0;
	rep(i, 1, n)rep(j, i + 1, n) {
		int p=lower_bound(d + 1+j, d + 1 + n, d[i] + d[j])-d;
		//ans +=max(0ll, p - 1 - j);
		ans +=  p - 1 - j;
	}
	cout << ans << endl;
	cin >> n;
}         
/*


*/


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

#define int long long

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

string K;
int D;
int dp[11111][2][111]; // dp[i桁目][未満フラグ][mod Dした値] = 総数

signed main() {
  cin >> K >> D;

  dp[0][0][0] = 1; // 初期化
  // DP
  for (int digit = 0; digit < K.size(); digit++) {
    for (int smaller : {0, 1}) {
      for (int modD = 0; modD < D; modD++) {
        int lim = (smaller ? 9 : K[digit] - '0');
        for (int num = 0; num <= lim; num++) {
          Add(dp[digit+1][smaller || (num < lim)][(modD + num) % D], dp[digit][smaller][modD]);
        }
      }
    }
  }

  int ans = 0;
  for (int smaller : {0, 1}) {
    Add(ans, dp[K.size()][smaller][0]);
  }

  // int ans = rec(0, 0, 0); // メモ化再帰に投げる
  Add(ans, -1LL); // 0になる場合の数を引く
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18688
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[4] = {} , b[4] = {} , c[4][4] = {};
    for( int i = 1 ; i <= 3 ; i++ ) {
        for( int j = 1 ; j <= 3 ; j++ ) cin >> c[i][j];
    }
    a[2]=c[2][1] - c[1][1];
    a[3]=c[3][1] - c[1][1];
    b[1]=c[1][1];
    b[2]=c[1][2];
    b[3]=c[1][3];
    for( int i = 1 ; i <= 3 ; i++ ) {
        for( int j = 1 ; j <= 3 ; j++ ) {
            if( ( a[i] + b[j] ) != c[i][j] ) {
                cout << "No" ;
                return 0;
            }
        }
    }
    cout << "Yes";
}


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

int main() {
  string s;
  cin >> s;
  for ( int i=0; i<s.size(); i++ ) {
    if ( s[i]=='?' ) {
      s[i]='D';
    }
  }
  cout << s << '\n';
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    Graph graph(N, vector<ll>(N));
    rep(i, N) {
        rep(j, N) {
            ll a;
            cin >> a;
            graph[i][j] = a;
        }
    }
    vector<vector<bool>> use(N, vector<bool>(N, true));
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                if (graph[i][k] + graph[k][j] < graph[i][j]) {
                    cout << -1 << '\n';
                    return;
                } else if (i != k && j != k && graph[i][k] + graph[k][j] == graph[i][j]) {
                    use[i][j] = false;
                }
            }
        }
    }
    ll ans = 0;
    rep(i, N) {
        rep(j, N) {
            ans += (use[i][j] ? graph[i][j] : 0);
        }
    }
    cout << ans / 2 << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define N 1000010
#define mo 998244353
#define ni (mo+1)/2
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
ll n,v[N],su,a[N];
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
void fwt(ll *a,int fh){
	for (int i=1;i<(1<<n);i*=2){
		for (int j=0;j<(1<<n);j+=i*2){
			for (int k=0;k<i;k++){
				ll x=a[j+k],y=a[j+k+i];
				if (fh==1){a[j+k]=(x+y)%mo;a[j+k+i]=(x-y+mo)%mo;}
				else{a[j+k]=(x+y)*ni%mo;a[j+k+i]=(x-y+mo)*ni%mo;}
			}
		}
	}
}
int main(){
	read(n);
	for (int i=0;i<(1<<n);i++){read(v[i]);su+=v[i];}
	for (int i=0;i<(1<<n);i++)v[i]=v[i]*po(su,mo-2)%mo;
	v[0]=(v[0]-1+mo)%mo;
	for (int i=0;i<(1<<n);i++)if (i==0)a[i]=(1<<n)-1;else a[i]=mo-1;
	fwt(a,1);fwt(v,1);
	for (int i=0;i<(1<<n);i++)a[i]=a[i]*po(v[i],mo-2)%mo;
	fwt(a,-1);
	for (int i=(1<<n)-1;i>=0;i--)a[i]=(a[i]-a[0]+mo)%mo;
	for (int i=0;i<(1<<n);i++)cout<<a[i]<<'\n';
	return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a1,b,c,d;
  long a[4] = {0L,0L,0L,0L};
  long max = -1000000000000000000L;
  
  cin >> a1 >> b >> c >> d;
  a[0] = a1*c;
  a[1] = a1*d;
  a[2] = b*c;
  a[3] = b*d;
  
  for(int i = 0;i < 4;i ++){
    if(max < a[i]){
      max = a[i];
    }
  }
    
  
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 3624
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(input[i]);
        }
        Array.Sort(a);
        for (int i = 0; i < n-1; i++)
        {
            if (a[i] == a[i + 1])
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine("YES");
    }
}

Measured memory_bytes: 31324
import sys

input = sys.stdin.readline

def main():
    while True:
        h,w = map(int, input().split())
        
        if h ==0 and w == 0:
            sys.exit()
        for i in range(h):
            for k in range(w):
                if i % 2 == 0:
                    if k % 2 == 0:
                        print("#", end="")
                    else:
                        print(".", end="")
                elif i % 2 == 1:
                    if k % 2 == 0:
                        print(".", end="")
                    else:
                        print("#", end="")
            print("")
        print("")
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 7024
#include <stdio.h>
#define MAX 100000
#define NIL -1

struct Node {int parent,left,right;};
struct Node T[MAX];

int n,D[MAX];

void setDepth(int,int);
void printChildren(int);


void setDepth(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL)
    setDepth(T[u].right,p);
  if(T[u].left!=NIL)
    setDepth(T[u].left,p+1);
}
void printChildren(int u){
  int c,i;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);
  if(T[u].parent==NIL)
    printf("root, ");
  else if(T[u].left==NIL)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  c=T[u].left;
  while(c!=NIL){
    printf("%d",c);
    c=T[c].right;
    if(c!=NIL) printf(", ");
  }
  printf("]\n");
}
int main(){
  int i,j,v,d,l,c,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)T[v].left=c;
      else T[l].right=c;
      l=c;
      T[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==NIL)r=i;
  }
  setDepth(r,0);
  for(i=0;i<n;i++)
    printChildren(i);
  return 0;
    }
    
  


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
unsigned long long fun[100];
int main()
{
	int n;
	cin>>n;
	fun[1]=2;
	fun[2]=1;
	for(int i=3;i<=89;i++)
		fun[i]=fun[i-1]+fun[i-2];
	cout<<fun[n+1];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define M 1000000007

int32_t main()
{   fast

    int n;
    cin>>n;
    int l[n];

    for(int i=0;i<n;i++)
    {
        cin>>l[i];
    }
    sort(l,l+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {   int k=i+2;
        for(int j=i+1;j<n;j++)
        {
           while(k<n&&l[i]+l[j]>l[k]) k++;
           //if(k>j)
           ans+=k-j-1;
        }
    }
    cout<<ans;
    return 0;
}


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

int main()
{
    int nx, ny, tx, ty;
    cin >> nx >> ny >> tx >> ty;

    for (int i = ny; i < ty; i++) cout << "U";
    for (int i = nx; i < tx; i++) cout << "R";

    for (int i = ny; i < ty; i++) cout << "D";
    for (int i = nx; i < tx; i++) cout << "L";

    cout << "L";
    for (int i = ny; i < ty; i++) cout << "U";
    cout << "U";
    for (int i = nx; i < tx; i++) cout << "R";
    cout << "RDR";
    for (int i = ny; i < ty; i++) cout << "D";
    cout << "D";
    for (int i = nx; i < tx; i++) cout << "L";
    cout << "LU";

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<stack>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}
int main(){
	string S;
	cin >> S;
	map<char, ll>mp;
	for(ll i=0; i<S.size(); i++){
		for (char c = 'a'; c <= 'z'; c++) {
			if (S[i] == c){
			mp[c  ]++;
            }
		}
	}
	string ans= "yes";
	for (char c='a'; c<='z'; c++) {
		if (mp[c] > 1){
			ans="no";
        }
    }
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
 
int main (){
  string S;
  cin>>S;
  int x=0;
  rep(i,S.length()){
    x+=S[i]-'0';
  }
  if(x%9==0)cout<<"Yes";
  else cout<<"No";
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
ll n,ans;
vector<int> abcd(4);

  
int main(){
  vector<int> abcd(4);
  int a;
  cin >> a;
  rep(i,4){
    abcd[i]=a%10;
    a/=10;
  }
  bool X=true;
  reverse(abcd.begin(),abcd.end());
  /*rep(i,4){
    cout << abcd[i];
  }
  cout << endl*/;
  for(int bit=0;bit<(1<<4);bit++){
    string s="";
    int sum =abcd[0];
    for(int i=0;i<3;i++){
      if(bit&(1<<i)){
        sum+=abcd[i+1];
        s += '+';
      }else{
        sum-=abcd[i+1];
        s += '-';
      }
    }
    if(sum==7){
      rep(i,3){
        cout << abcd[i] << s[i];
      }
      cout << abcd[3] << "=7" << endl;
      X = false;
    }
    if(!X) break;
  }
  return 0;
}

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

int main(){
	string s1,s2;
	cin >> s1 >> s2;
	int l1 = s1.length(),l2 = s2.length();
	int dp[l1+1][l2+1];

	for(int i=0;i<=l1;i++){
		for(int j=0;j<=l2;j++){
			if(i == 0) dp[0][j] = j;
			else if(j == 0) dp[i][0] = i;
			else if(s1[i-1] == s2[j-1]) dp[i][j] = dp[i-1][j-1];
			else{
				int a = dp[i-1][j] + 1;
				int b = dp[i][j-1] + 1;
				int c = dp[i-1][j-1]+1;
				dp[i][j] = min(min(a,b),c);
			}
		}
	}
	cout << dp[l1][l2] << endl;
	
}

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

using namespace std;

typedef long long ll;

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

	int n, m;
	cin >> n >> m;

	int stux[n], stuy[n];
	rep(i, n){
		cin >> stux[i] >> stuy[i];
	}

	int chkx[m], chky[m];
	rep(i, m){
		cin >> chkx[i] >> chky[i];
	}

	rep(i, n){		
		int mindis = INT_MAX / 2;
		int minid = -1;
		rep(j, m){
			int dis = abs(stux[i] - chkx[j]) + abs(stuy[i] - chky[j]);
			if(dis < mindis){
				mindis = dis;
				minid = j;
			}
		}

		cout << minid + 1 << endl;		
	}
}


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

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) a.begin(), (a).end()
#define inf = 9876543210
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; 
    cin >> a >> b;
    int ans = 0;
    for (int c = 1; c<=3; c++){
        if ((a * b * c) % 2 == 1){
            ans = 1;
        }        
    }
    if (ans == 1){
        print("Yes");
    }
    else{
        print("No");
    }
return 0;
}

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

int main() {
  long int n, s = 0, x;
  cin >> n;

  vector<int> k(10);

  for (int i = 0; i < 10; i++) {
    x = (n % (int)pow(10, i + 1)) / (int)pow(10, i);
    s += x;
  }

  if (n % s == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ls x<<1
#define rs x<<1|1
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,t,q;

ll a[N],k;

bool check(ll mid){
    ll cnt=0;
    rep(i,1,n){
        if(a[i]==0){
            if(mid>=0)cnt+=(n-1);
        }
        else if(a[i]<0){
            ll num;
            if(mid>0){
                num=mid/a[i];
            }
            else if(mid<0){
                num=mid/a[i];
                if(mid%a[i])num++;
            }
            else if(mid==0)num=0;
            ll id=a+n+1-lower_bound(a+1,a+n+1,num);
            if(id!=0&&a[n+1-id]<=a[i])id--;
            cnt=cnt+id;
        }
        else{
            ll num;
            if(mid>0){
                num=mid/a[i];
            }
            else if(mid<0){
                num=mid/a[i];
                if(mid%a[i])num--;
            }
            else if(mid==0)num=0;
            ll id=upper_bound(a+1,a+n+1,num)-a-1;
            if(id!=0&&a[id]>=a[i])id--;
            cnt=cnt+id;
        }
    }
    cnt=cnt/2;
    return cnt>=k;
}


int main(){
    scanf("%d%lld",&n,&k);
    rep(i,1,n)scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    ll l=-1e18,r=1e18,ans=1e18;
    while(l<=r){
        ll mid=(l+r)>>1;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (binary me 1 kitne hai) (if longlong popcount ll)
#define ln "\n"
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(n) n.begin() , n.end() 
#define tfi first.first
#define tse first.second
#define tth second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef pair< pair<int,int> , int> tri;

#pragma GCC optimize ("-O2")
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); }
const int LIM = 2e5+5 ,MOD = 1e9+7;
const ll inf = 10000000000;
//int n , m , t , x ,y ;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

	ll n, wei;
	cin >> n >> wei;

	ll w[n+1], v[n+1];
	forn(i,n) cin >> w[i+1] >> v[i+1];

	ll dp[n+1][100001];

	forn(i,n+1) dp[i][0]=0;
	forsn(i,1,100001) dp[0][i]=inf;

	forsn(j,1,100001) forsn(i,1,n+1){
		if(j>=v[i]) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
		else dp[i][j] = dp[i-1][j];
	}

	for(int i=100000; i>=0; i--){
		if(dp[n][i]<=wei){
			cout << i;
			break;
		}
	}

}

Measured memory_bytes: 79232
#include<stdio.h>
int x[200000],y[200000];
int main(){
  int min,i,j,nx,ny,t,r,w,h;
  char m[101][101];
  int X[]={0,1, 0,-1};
  int Y[]={1,0,-1, 0};
  while(scanf("%d %d",&w,&h),w||h){
    int c[101][101]={0};
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf(" %c",&m[i][j]);
	if(m[i][j]=='&'){
	  m[i][j]='.';
	  y[0]=i;
	  x[t=0]=j;
	  c[i][j]=1;
	}
      }
    }
    for(r=1;r-t;t++){
      for(i=0;i<4;i++){
	nx=x[t]+X[i];
	ny=y[t]+Y[i];
	if(nx<0||w<=nx||ny<0||h<=ny)continue;
	if(m[y[t]][x[t]]==m[ny][nx]){
	  if(c[y[t]][x[t]]<c[ny][nx]||0==c[ny][nx]){
	    c[ny][nx]=c[y[t]][x[t]];
	    x[r  ]=nx;
	    y[r++]=ny;
	  }
	}
	else{
	  if(c[y[t]][x[t]]+1<c[ny][nx]||0==c[ny][nx]){
	    c[ny][nx]=c[y[t]][x[t]]+1;
	    x[r  ]=nx;
	    y[r++]=ny;
	  }
	}
      }
    }
    /*for(i=0;i<h;i++){
      for(j=0;j<w;j++)printf("%d",c[i][j]);
      printf("\n");
      }*/
    min=w;
    for(i=0;i<w;i++){
      if(c[0  ][i]/2<min)min=c[0  ][i]/2;
      if(c[h-1][i]/2<min)min=c[h-1][i]/2;
    }
    for(i=0;i<h;i++){
      if(c[i][0  ]/2<min)min=c[i][0  ]/2;
      if(c[i][w-1]/2<min)min=c[i][w-1]/2;
    }
    printf("%d\n",min);
  }
  return 0;
}

Measured memory_bytes: 1952
#include <iostream>

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

using ll = long long;

int main() {
    int  n;
    bool odd_negatives = false;
    bool zero_included = false;
    ll   ans = 0LL;
    ll   minimum_elem = (ll) 1e9 + 1;

    ll  a[N];
    std::cin >> n;
    rep(i, n) {
        std::cin >> a[i];
        if (a[i] < 0)  odd_negatives = !odd_negatives;
        if (a[i] == 0) zero_included = true;
        a[i] = std::abs(a[i]);
    }

    rep(i, n) {
        ans += a[i];
        if (a[i] < minimum_elem) minimum_elem = a[i];
    }

    if (odd_negatives && !zero_included) ans -= 2*minimum_elem;

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    private final static Scanner sc = new Scanner(System.in);

    /**
     * joisinoお姉ちゃん達が使ってる紙です
     *
     * @author parikkus
     *
     */
    public static class Paper {
        Map<Long, Long> writeNumberCountMap = new HashMap<>();


        public void joisinoCall(Long num) {
            putCountMap(writeNumberCountMap, num);
        }

        public long numberCount() {
            return writeNumberCountMap.values().parallelStream().filter(i -> (i & 1) == 1).count();
        }

        private static void putCountMap(Map<Long, Long> map, Long value) {
            if (map.containsKey(value)) {
                map.put(value, map.get(value) + 1L);
            } else {
                map.put(value, 1L);
            }
        }
    }

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        int n = nextInt();
        Paper p = new Paper();

        for (int i = 0; i < n; i++) {
            p.joisinoCall(sc.nextLong());
        }

        out(p.numberCount());
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt() {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString() {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

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

Measured memory_bytes: 64948
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
using namespace std;
#define MAX 10000000000;


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

	int players, scores, quiz; cin >> players >> scores >> quiz; 
	
	vector<int> arr(players);
	for (int i = 0; i < arr.size(); i++) {
		arr[i] = scores - quiz;
	}

	int p; 
	for (int i = 0; i < quiz; i++) {
		cin >> p;
		p -= 1;
		arr[p] += 1;
	}

	for (int i = 0; i < players; i++) {
		if (arr[i] > 0) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}


	return 0;
} 



Measured memory_bytes: 1024
n=int(input())
lis=list(map(int,input().split()))
su=sum(lis)
sumodd=0
for i in range(int((n-1)/2)):
  sumodd+=lis[2*i+1]
mout=su-sumodd*2
print(mout,end='')
for m in range(n-1):
  mout=2*lis[m]-mout
  print(' %d' % mout,end='')

Measured memory_bytes: 14028
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
    //cout << fixed << setprecision(8);

    int N;
    while(cin >> N, N){
        vector<vector<int>> days(51);
        for(int i=0; i<N; ++i){
            int c; cin >> c;
            for(int j=0; j<c; ++j){
                int d; cin >> d;
                days[d].push_back(i+1);
            }
        }
        
        
        set<int> st[51];
        for(int i=1; i<=N; ++i){
            st[i].insert(i);
        }
        
        int i = 1;
        for(; i<31; ++i){
            for(int j=0; j<(int)days[i].size(); ++j){
                for(int k=0; k<(int)days[i].size(); ++k){
                    for(auto e: st[days[i][k]]){
                        st[days[i][j]].insert(e);
                    }
                }
            }
            bool c = false;
            for(int j=1; j<=N; ++j) {
                if ((int)st[j].size() == N) {
                    c = true;
                    break;
                }
            }
            if(c) break;
        }

        if(i==31) cout << -1 << endl;
        else cout << i << endl;
    }
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    long long int invariant = 0;
    long long int numW = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'W') {
            numW++;
            invariant += i;
        }
    }
    cout << invariant - numW * (numW - 1) / 2 << endl;
}

Measured memory_bytes: 640
N,Q = map(int,input().split())
S = input()

lr = [list(map(int,input().split())) for i in range(Q)]

cnt = 0
li = []

for i in range(len(S)):
    if i == len(S)-1:
        li.append(cnt)
    elif S[i] == "A" and S[i+1] == "C":
        li.append(cnt)
        cnt += 1
    else:
        li.append(cnt)

#print(li)
#exit()

for k in range(Q):
    print(li[lr[k][1]-1] - li[lr[k][0]-1])


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

int main() {
	int N,A;
	cin >> N;
	vector<int> r(N,0);

	rep(i,N-1) {
		cin >> A;
		++r.at(A-1);
	}

	rep(i,N)
		cout << r.at(i) << endl;
}

Measured memory_bytes: 3984
n, y = gets.split.map(&:to_i)

0.upto(n) do |a|
  0.upto(n) do |b|
    c = n - a - b
    next if c.negative?
    if (a * 10_000 + b * 5_000 + c * 1_000) == y
      puts [a,b,c] * ' '
      exit
    end
  end
end
puts '-1 -1 -1'

Measured memory_bytes: 1788
import Data.List
import Control.Monad
import qualified Data.IntSet as S

main=do
    n<-readLn::IO Int
    as<-map read.words<$>getLine::IO[Int]
    putStrLn.unwords.(\(s,c)->[show$ max 1 $ S.size s, show$ (S.size s + c)]).foldl' f (S.empty,0) $ as
--
f (st,c) a
    | a< 400 = (S.insert 0 st, c)
    | a< 800 = (S.insert 1 st, c)
    | a<1200 = (S.insert 2 st, c)
    | a<1600 = (S.insert 3 st, c)
    | a<2000 = (S.insert 4 st, c)
    | a<2400 = (S.insert 5 st, c)
    | a<2800 = (S.insert 6 st, c)
    | a<3200 = (S.insert 7 st, c)
    | True   = (st, c+1)


Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        var z = S.Zip(T, (first, second) => new char[] { first, second });
        int ans = 0;
        foreach (var v in z) if (v[0] != v[1]) ans++;
        Console.WriteLine(ans);
        return;
    }
    IEnumerable<TResult> Zip<TResult, T1, T2>
        (IEnumerable<T1> a,
         IEnumerable<T2> b,
         Func<T1, T2, TResult> combine)
    {
        using (var f = a.GetEnumerator())
        using (var s = b.GetEnumerator())
        {
            while (f.MoveNext() && s.MoveNext())
                yield return combine(f.Current, s.Current);
        }
    }
}

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

using namespace std;

#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

// template<typename T>
// istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  i64 n, m, v, p;
  while (cin >> n >> m >> v >> p) {
    llvec a(n);
    forn(i, n) {
      cin >> a[i];
    }

    sort(a.rbegin(), a.rend());
    llvec sa(n + 1);
    sa[0] = 0;
    forn(i, n) {
      sa[i + 1] = sa[i] + a[i];
    }

    logv(a);
    logv(sa);

    i64 ans = p;
    logss(n, m);
    logss(v, p);
    forr(i, p, n) {
      if (a[i] + m < a[p - 1])  {
        break;
      }
      i64 vs = m * v;
      vs -= (p - 1) * m + (n - i) * m;

      if (vs <= 0) {
        ans++;
        continue;
      }

      logss(a[i] + m, i);

      i64 ns = (a[i] + m) * (i - p + 1);
      ns -= sa[i] - sa[p - 1];
      logss(vs, ns);
      if (ns >= vs) {
        ans++;
      } else {
        break;
      }
    }

    cout << ans << endl;
  }
}

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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int n, k;
  cin >> n >> k;
  vector<long long> A(n);
  for (auto &a : A) {
    cin >> a;
  }

  for (int i = k; i < n; i++) {
    if (A[i] > A[i - k]) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}

Measured memory_bytes: 4780
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
lcm = a[0]
for i in range(1,n):
  lcm = lcm*a[i] // gcd(lcm,a[i])
mod=pow(10,9)+7
lcm%=mod
ans=0
for x in a:
  ans+=pow(x,mod-2,mod)
  ans%=mod
print(ans*lcm%mod)


Measured memory_bytes: 6204