akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

#define LL long long
#define MAXN 100000
#define MOD 1000000007
LL fac[2*MAXN+5];
LL inv[2*MAXN+5];

LL Pow(LL x,LL p){
    LL ret=1;
    while(p){
        if(p&1)
            ret=ret*x%MOD;
        x=(x*x)%MOD;
        p>>=1;
    }
    return ret;
}

void Prep(int N){
    fac[0]=1;
    for(int i=1;i<=N;i++)
        fac[i]=fac[i-1]*i%MOD;
    inv[0]=1;
    inv[N]=Pow(fac[N],MOD-2);
    for(int i=N-1;i>=1;i--)
        inv[i]=inv[i+1]*(i+1)%MOD;
}

LL C(int m,int n){
    return fac[m]*inv[n]%MOD*inv[m-n]%MOD;
}

int main(){
    int H,W,A,B;
    scanf("%d%d%d%d",&H,&W,&A,&B);
    Prep(H+W);
    LL Ans=0;
    for(int i=B+1;i<=W;i++){
        LL tmp1=C(H-A+i-2,i-1);
        LL tmp2=C(A+W-i-1,W-i);
        Ans=(Ans+(tmp1*tmp2)%MOD)%MOD;
    }
    printf("%lld",Ans);
}

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

int main() {
	ll X;
	cin >> X;

	for(ll i=-1000; i<=1000; ++i)
		for(ll j=-1000; j<=1000; ++j)
			if(pow(i,5)-pow(j,5) == X) {
				cout << i << " " << j << endl;
				return 0;
			}
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
    double x, y;
};
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;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int be = a[0];
    ll ans = 0;
    repi(i, 1, n) {
        if (be <= a[i]) {
            be = a[i];
            continue;
        }
        ans += (be - a[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;


void find(int n,int x,int m){
    int sum = x;
    for(int i = 2; i <= n; i++){
        x = (x * x) % m;
        sum += x;
    }
    cout << sum ;
}

void solve(){
    int n,x,m;
    cin >> n >> x >> m ;
    if(n <= (1e6)){
        find(n,x,m);
        return;
    }
    
    vector<int> v;
    map<int,int> mp;

    v.pb(x);
    mp[x] = 0;
    int val = -1;
    
    for(int i = 2; ; i++){
        x = (x * x) % m;
        if(mp.find(x) != mp.end()){
            val = x;
            break;
        }
        v.pb(x);
        mp[x] = i - 1;
    }
    // cout << val << " " << mp[val] << '\n' ; 
    int sum = 0,ind = mp[val];
    int tot = (int)v.size();
    for(int i = 0; i < ind; i++){
        sum += v[i];
    }
    n -= (ind);
    vector<int> pref;
    for(int i = ind; i < tot; i++){
        pref.pb(v[i]);
    }
    tot = (int)pref.size();
    for(int i = 1; i < tot; i++){
        pref[i] += pref[i - 1];  
    }
    int times = n / (tot);
    sum += (pref[tot - 1]) * times;
    int remain = n % (tot);
    if(remain >= 1)
        sum += pref[remain - 1];
    cout << sum;
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll pow_mod(ll a, ll n, ll p)
{
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*a%p;
        a = a*a%p;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll i,j;
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll> a(n,0);
    vector<ll> l(n,0);
    vector<ll> r(n,0);
    vector<ll> c(n,0);
    if(s[0] == 'A') a[0] = 1;
    if(s[0] == '?') l[0] = 1;
    for(i = 1;i < n;++i){
        a[i] = a[i-1];
        l[i] = l[i-1];
        if(s[i] == 'A') a[i]++;
        if(s[i] == '?') l[i]++;
    }
    if(s[n-1] == 'C') c[n-1] = 1;
    if(s[n-1] == '?') r[n-1] = 1;
    for(i = n-2;i >= 0;--i){
        c[i] = c[i+1];
        r[i] = r[i+1];
        if(s[i] == 'C') c[i]++;
        if(s[i] == '?') r[i]++;
    }
    ll ans = 0;
    const ll MOD = 1e9+7;
    for(i = 1;i <= n-2;++i){
        if(s[i] == 'B' || s[i] == '?'){
            ans += (a[i-1]*pow_mod(3, l[i-1], MOD)%MOD + l[i-1]*pow_mod(3, l[i-1]-1, MOD)%MOD)%MOD*(c[i+1]*pow_mod(3, r[i+1], MOD)%MOD + r[i+1]*pow_mod(3, r[i+1]-1, MOD)%MOD)%MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6688
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    ll n;
    cin >> n;
    ll x[51], y[51];
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    map<P, ll> mp;
    mp[P(0, 0)] = -10000;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            mp[P(x[i] - x[j], y[i] - y[j])]++;
        }
    }
    ll lar = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        lar = max(lar, itr -> second);
    }
    cout << n - lar << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
int main(){
  ll A,B,C,X,Y;
  cin >> A>>B>>C>>X>>Y;
  ll all  =10000000000;
  for(ll i=0;i<=200000;i+=2){
    ll ans =0;
    ans += i*C;
    if(i/2<X)ans+=(X-i/2)*A;
    if(i/2<Y)ans+=(Y-i/2)*B;
    all = min(ans,all);
  }
  cout<<all<<endl;

}

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}



int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

     cin>>t;

     string str;
     map<string,ll>mp;
     while(t--)
     {
         cin>>str;

         mp[str]++;
     }

     cout<<"AC x "<<mp["AC"]<<endl<<"WA x "<<mp["WA"]<<endl<<"TLE x "<<mp["TLE"]<<endl<<"RE x "<<mp["RE"]<<endl;

    //0


}



Measured memory_bytes: 3608
N = int(input())
H = list(map(int, input().split()))

C = [0] * N
C[1] = abs(H[1] - H[0])

for c in range(2, N):
    C[c] = min(abs(H[c] - H[c-1]) + C[c-1], abs(H[c] - H[c-2]) + C[c-2])

print(C[N-1])


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 100005;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<vector<int> > G(MAX, vector<int>());
int N;
/* function */
vector<int> bfs(int st) {
    queue<int> q;
    vector<int> dist(N, -1);
    dist[st] = 0;
    q.push(st);
    while (!q.empty()) {
        int from = q.front(); q.pop();
        for (int to : G[from]) {
            if (dist[to] != -1) continue;
            dist[to] = dist[from] + 1;
            q.push(to);
        }
    }
    return dist;
}

/* main */
int main(){
    cin >> N;
    int a, b;
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> distF = bfs(0);
    vector<int> distS = bfs(N - 1);
    int cntS = 0, cntF = 0;
    for (int i = 0; i < N; i++) {
        if (distF[i] <= distS[i]) cntF++;
        else cntS++;
    }
    if (cntF > cntS) cout << "Fennec" << '\n';
    else cout << "Snuke" << '\n';
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,j,k,l,sum=0;
    string a,b,c;
    cin>>n>>a>>b>>c;
    
    for(int i=0;i<n;i++){
        j=(int)(a[i]!=b[i])+(int)(a[i]!=c[i]);
        k=(int)(b[i]!=a[i])+(int)(b[i]!=c[i]);
        l=(int)(c[i]!=a[i])+(int)(c[i]!=b[i]);
        
        if(j<k){
            if(l<j){
                sum+=l;
            }else{
                sum+=j;
            }
        }else{
            if(l<k){
                sum+=l;
            }else{
                sum+=k;
            }
        }
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 256
while 1:
	n=input()
	if n==0:break
	for i in range(n):
		m,e,j=map(int, raw_input().split())
		a=m+e+j
		if 100 in [m,e,j] or m+e>179 or a>239:print "A"
		elif a>209 or (a>149 and max(m,e)>79):print "B"
		else:print"C"

Measured memory_bytes: 4212
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int[][] arr = new int[N][2];
        for (int i = 0; i < N; i++) {
            arr[i][0] = Integer.parseInt(scanner.next());
            arr[i][1] = Integer.parseInt(scanner.next());
        }
        scanner.close();

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

        double total = 0;
        int count = 0;

        do {
            for (int i = 0; i < N - 1; i++) {
                total += Math.sqrt(Math.pow(arr[index[i]][0] - arr[index[i + 1]][0], 2) + Math.pow(arr[index[i]][1] - arr[index[i + 1]][1], 2));
            }
            count++;
        } while (findNextPermutation(index));
        System.out.println(total / count);
    }

    private static int[] swap(int[] data, int left, int right) {
        int temp = data[left];
        data[left] = data[right];
        data[right] = temp;
        return data;
    }

    private static int[] reverse(int[] data, int left, int right) {
        while (left < right) {
            swap(data, left, right);
            left++;
            right--;
        }
        return data;
    }

    private static boolean findNextPermutation(int[] data) {
        if (data.length <= 1) return false;

        int last = data.length - 2;

        // find the longest non-increasing suffix
        // and find the pivot
        while (last >= 0) {
            if (data[last] < data[last + 1]) {
                break;
            }
            last--;
        }

        // If there is no increasing pair
        // there is no higher order permutation
        if (last < 0) return false;

        int pivot = data.length - 1;

        // 末尾から昇順が終わる位置を探す
        for (int i = data.length - 1; i > last; i--) {
            if (data[i] > data[last]) {
                pivot = i;
                break;
            }
        }

        // Swap the successor and the pivot
        swap(data, pivot, last);

        // Reverse the suffix
        reverse(data, last + 1, data.length - 1);

        return true;
    }
}



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

int main() {
  
  string S;
  
  int num;
  int answer = -90;
  
  cin >> S;

  for(int i = 0;i < S.size();++i){
    num = 0;
    for(int j = 0;j < S.size() - i;++j){
      if(!(S[i + j] == 'A' || S[i + j] == 'C' || S[i + j] == 'G' || S[i + j] == 'T')){
        goto end;
      }
      else{
        num++;
      }
    }
    end:
    answer = max(answer,num);
  }

cout << answer << endl;}



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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] b = new int[n-1];
		int [] a = new int[n];
		int ans = 0;
		b[0] = stdIn.nextInt();
		a[0] = b[0];
		ans += a[0];
		a[1] = b[0];
		for(int i = 1; i < b.length; i++) {
			b[i] = stdIn.nextInt();
			
			if(b[i-1] >= b[i]) {
				a[i] = b[i];
				a[i+1] = b[i];
			}else {
				a[i+1] = b[i];
			}
		}
		
		for(int i = 1; i < a.length; i++) {
			ans += a[i];
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
n = int(input())
a = list(map(int,input().split()))
count = 0

for i in range(10**10):
  for j in range(n):
    if a[j]%2 != 0:
      print(count)
      exit()
    else:
      a[j] = a[j]//2
  count += 1
  

Measured memory_bytes: 2940
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

ll k;
ll flip[2] = { +1, +1 };
void print(vl p) {
    cout << (p[0] * flip[0]) << " " << (p[1] * flip[1]) << "\n";
}

ll dist(vl a, vl b) {
    return abs(a[0] - b[0]) + abs(a[1] - b[1]);
}

vl move(vl curr, vl to) {
    ll xx = to[0] - curr[0];
    xx = min(k, xx);
    ll yy = k - xx;
    vl moved = curr;
    moved[0] += xx;
    moved[1] += yy;
    if (moved[0] > to[0]) { moved[0] = curr[0] - xx; }
    if (moved[1] > to[1]) { moved[1] = curr[1] - yy; }

    return moved;
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll x, y;
    cin >> k >> x >> y;
    if (x < 0) { flip[0] = -1; x = -x; }
    if (y < 0) { flip[1] = -1; y = -y; }
    vl to = { x, y };

    vvl ans;

    if (x + y == k) {
        cout << 1 << endl;
        print({x, y});
        return 0;
    }

    if ((x + y) % 2 == 1 && k % 2 == 0) { cout << -1 << endl; return 0; }

    vl curr = { 0, 0 };

    while (true) {
        if (curr == to) { break; }
        ll d = dist(curr, to);
        if (d == k) { ans.pb(to); break; }
        bool fucked = (to[0] + to[1] - curr[0] - curr[1]) % 2 == 1;
        if (d > 2 * k || fucked) {
            curr = move(curr, to);
            ans.pb(curr);
            continue;
        }
        ll dx = to[0] - curr[0];
        ll dy = to[1] - curr[1];
        assert((dx + dy) % 2 == 0);
        ll dd = (dx + dy) / 2;
        vl mid;
        if (dx > dy) {
            mid = to;
            mid[0] -= dd;
            mid[1] += (k - dd);

        } else {
            mid = curr;
            mid[1] += dd;
            mid[0] -= (k - dd);
        }
        ans.pb(mid);
        ans.pb(to);
        break;
    }

    cout << sz(ans) << endl;
    for (vl p : ans) print(p);
    cout << endl;

    return 0;
}


Measured memory_bytes: 14124
a = list(map(int, input().split()))
x=max(a)
dif=[x-a[0],x-a[1],x-a[2]]
dif.sort()
dif1=dif[2]-dif[1]
if dif1%2==0:
    ans=dif[1]+dif1/2
else:
    ans=dif[1]+(dif1-1)/2+2
print(int(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w;
	map<char,int>dis;
	bool ans=true;
	int four=0;
	int two=0;
	int one=0;
	cin >>h>>w;
	string s;
	rep(i,h){
		cin>>s;
		rep(j,w){
			dis[s[j]]+=1;
		}
	}
	repi(itr,dis){
	//	cout<<(itr->F)<<" "<<(itr->S)<<endl;
		if((itr->S)%4){
			if(itr->S%2){
				one++;
			}else{
				two++;
			}
		}else{
			four++;
		}
	}
	clog << one << " " << two << " " << four << endl;
	if(one!=0 and not(h%2 and w%2 and one==1)){
		ans=false;
	}
	if(h%2){
		two-=w/2;
	}
	if(w%2){
		two-=h/2;
	}
	if(two >0){
		ans=false;
	}
	
	cout<<solve(ans)<<endl;
}
/*
2n 2m : 4m
2n+1 2m+1 ; 1 *1 , 2n*((m-1)+(n-1)/2) m, 4m
2n 2m+1  2n*(m-1/2),4n
*/

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>

int main(int argc, char** argv)
{
    int N,X;
    std::cin >> N;
    std::cin >> X;
    int D=0;
    int i=0;
    for(;i<N;i++)
    {
        int L;
        std::cin >> L;
        D=D+L;
        if(D>X){break;}
    }

    std::cout << i+1;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int side1, side2, diagonal, rectangle = 0, rhombus = 0;
    while(scanf("%d,",&side1) != EOF ) {
        scanf("%d,%d",&side2,&diagonal);
        if(side1 == side2) {
            rhombus++;
        }
        if(side1 * side1 + side2 * side2 == diagonal *diagonal) {
            rectangle++;
        }
    }
    printf("%d\n%d\n",rectangle,rhombus);
    return 0;
}

Measured memory_bytes: 596
N, x = map(int, input().split())
a = [int(i) for i in input().split()]

if sum(a) == x :
  print(N)
else :
  a.sort()
  s = 0
  for i in range(N) :
    if s + a[i] > x :
      break
    s += a[i]

  print(i)


Measured memory_bytes: 38384
N,L = map(int,input().split())
N_ = [i for i in range(1,N+1)]
L_ = [L+i-1 for i in range(1,N+1)]
t = 1000000
ans = 0
sum_L = sum(L_)
for i in range(N):
  target = sum_L - L_[i] 
  if abs(target - sum_L) < t:
    ans = target
    t = abs(target - sum_L)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<int> a(m), b(m);
    vector<vector<int>> c(m);
    rep(i,m) {
        cin>>a[i]>>b[i];
        rep(j,b[i]) {
            int d; cin>>d;
            --d;
            c[i].push_back(d);
        }
    }

    vector<vector<ll>> dp(m+1, vector<ll>((1<<n), LINF));
    rep(i,m) dp[0][0] = 0;

    rep(i,m) {
        for (int bit = 0; bit < (1<<n); ++bit) {
            int cur = bit;
            ll cost = a[i];
            int nxt = cur;
            for (auto &&e: c[i]) {
                nxt = nxt | (1<<e);
            }
            chmin(dp[i+1][cur], dp[i][cur]);
            chmin(dp[i+1][nxt], dp[i][cur]+cost);
        }
    }

    if (dp[m][(1<<n)-1] != LINF) cout << dp[m][(1<<n)-1] << '\n';
    else cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 32512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

vector<vl> a(22, vl(22, 0));
vector<vl> table(22, vl(1<<21, -1));

ll dp(ll n, ll b) {
  // cout << n << " " << b << endl;
  if (table[n][b] != -1) return table[n][b];
  ll v = 0;
  if (n == N) {
    ll r = 1;
    ll _b = b;
    while((_b & 1) == 0) {
      r++;
      _b >>= 1;
    }
    if (a[n][r] == 1) v = 1;
    else v = 0;
  } else {
    FOR(r, 1, N+1) {
      ll _b = (b >> (r-1)) & 1;
      if (_b == 1 && a[n][r] == 1) {
        v += dp(n+1, b - (1<<(r-1)));
        v %= MOD;
      }
    }
  }
  table[n][b] = v;
  return v;
}

int main(void){
  
  IN(N);
  FOR(i, 1, N+1) {
    FOR(j, 1, N+1) {
      IN(a[i][j]);
    }
  }

  ret = dp(1, (1<<N)-1);
  PRINT(ret);
  DEBUG("hogehoge");
  DEBUG(555);

}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  long n;
  cin >> n;
  long ans = 1;
  for (long i = 0; i < n; i++) {
    long tmp;
    cin >> tmp;

    if (tmp == 0) {
      ans = 0;
    } else if (ans != -1) {
      if (ans > 1000000000000000000 / tmp) {
        ans = -1;
      } else {
        ans *= tmp;
      }
    }
  }

  cout << ans << endl;
}


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

int main(void) {
    long long N, K;
    cin >> N >> K;

    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }

    long long sum = 0;

    for (long long b = K + 1; b <= N; b++) {
        long long period = N / b;
        sum += period * max(0ll, b - K) + max(0ll, (N % b) - K + 1ll);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {
	
	ll M1, D1, M2, D2;
	cin >> M1 >> D1 >> M2 >> D2;

	if (D2 == 1) cout << "1";
	else cout << "0";

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

ll N;
string checkstr = "357";
ll elems[3] = {3, 5, 7};

bool check(ll s) {
  string ss = to_string(s);
  rep(i, checkstr.size()) {
    size_t cnt = count(ss.begin(), ss.end(), checkstr[i]);
    if (cnt == 0) return false;
  }
  return true;
}

int dfs(ll s) {
  if (s > N) {
    return 0;
  }

  int ret = 0;
  if (check(s)) ret = 1;
  rep (i, 3) {
    ll new_s = s * 10;
    new_s += elems[i];
    ret += dfs(new_s);
  }
  return ret;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  ll n;
  cin>>n;
  ll ans=1;
  ll ans9=1,ans0=1,ans90=1;
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  rep(i,n){
    ans=ans*10%MOD;
    ans%=MOD;
    ans0=ans0*9%MOD;
    ans0%=MOD;
    ans9=ans9*9%MOD;
    ans9%=MOD;
    ans90=ans90*8%MOD;
    ans90%=MOD;
  }
  ll ansex=(ans-ans0-ans9+ans90)%MOD;
  if(ansex<0){
    ansex+=MOD;
  }
  cout<<ansex<<endl;
}

Measured memory_bytes: 3636
import heapq
N,K=  list(map(int,input().split(" ")))
nums = list(map(int,input().split(" ")))
nums = list(map(lambda x:-x , nums))
heapq.heapify(nums)
for _ in range(K):
    temp = heapq.heappop(nums)
    temp *= -1
    temp //= 2
    temp *= -1
    heapq.heappush(nums,temp)
nums = list(map(lambda x:-x , nums))
print(sum(nums))

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

bool isint( double x ){
  return static_cast<int32_t>(x)==x;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, d;
  cin >> n >> d;
  
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) {
    rep(j, d) {
      cin >> x.at(i).at(j);
    }
  }
  
  int ans = 0;
  rep(i, n-1) {
    for(int j = i+1; j < n; j++) {
      int dis = 0;
      for(int k = 0;k < d;k++) {
        dis += (x.at(i).at(k) -x.at(j).at(k))*(x.at(i).at(k) -x.at(j).at(k));
      }
      if(isint(sqrt(dis)))
        ans++;
    }
  }
  
  cout << ans << "\n";

}


Measured memory_bytes: 256
def gcd(a, b)
    while b != 0 do
       c = a % b; a = b; b = c;
    end
return a
end
t = gets.to_i
input = gets.split(" ").map{|item|item.to_i}
l=[]
r=[]
ans =[]
input.push(0)

l[0]=0
r[t+1]=0

t.times{|k|
l[k+1]=gcd(l[k],input[k])
r[t-k] = gcd(r[t-k+1], input[t-k])
}
l.each_with_index{|item,num|
ans.push(gcd(item,r[num+1]))}

print ans.max

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

int main(){

    int n, W;
    cin>>n>>W;
    long long v[n], wt[W], dp[n+1][W+1];

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

    for(int i=0; i<= n; i++){
        for(int w=0; w<=W; w++){
            if(i == 0 || w == 0){
                dp[i][w]=0;
            }
            else if(wt[i-1] <= w){
                dp[i][w] = max(v[i-1] + dp[i-1][w-wt[i-1]], dp[i-1][w]);
            }
            else{
                dp[i][w] = dp[i-1][w];
            }
        }
    }

    cout<<dp[n][W]<<endl;

}


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

int main()
{
    int a,b,c,d;
    //cin>>x>>y1>>x2>>y2;
   cin>>a>>b>>c>>d;
   int x=c-a;
   int y=d-b;
   cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func checkNum(x int) bool {
	if x%3 == 0 {
		return true
	}
	return false
}

func include3(x int) bool {
	for x != 0 {
		if x%10 == 3 {
			return true
		}
		x /= 10
	}
	return false
}

func main() {
	var n int
	fmt.Scan(&n)

	for i := range make([]int, n+1) {
		switch {
		case i == 0:
		case checkNum(i) || include3(i):
			fmt.Printf(" %d", i)
		}
	}
	fmt.Println()
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

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

int main()
{
    cout << fixed << setprecision(15);

    ll H, W, sx, sy, gx, gy;
    cin >> H >> W;
    cin >> sx >> sy;
    cin >> gx >> gy;
 
    // indexが0からなので1減らす
    sx--; sy--; gy--; gx--;

    vector<string> S(H);
    REP(i, H){
        cin >> S[i];
    }
    vector<vector<ll>> v(H, vector<ll>(W, LINF));
 
    // キューを準備
    deque<P> que;

    // 探索の初期値を入れる
    que.emplace_back(sx, sy);
    v[sx][sy] = 0;

    while(true) {
        //　もしも探索地点がゴールならば現在の歩数を探索終了
        if(que.empty()) {
            break;
        }
        // キューの中身を取り出す
        P p = que.front(); que.pop_front();
        int x = p.first;
        int y = p.second;
        int s = v[x][y];

        // if(v[x][y] != s) continue;

        // 4方向へ繰り返す
        REP(i, 4) {
            int nx = x+dx[i];
            int ny = y+dy[i];
            // 移動すると範囲外になったり、#だったり、探索済みだったら終了する
            if(nx < 0 || nx >= H || ny < 0 || ny >= W
                || v[nx][ny] <= s || S[nx][ny] == '#') continue;
            // 未探索だったら、キューに入れて現在の距離を記録
            que.emplace_front(nx, ny);
            v[nx][ny] = s;
        }

        // ワープを使う場合
        for(ll ei=-2; ei<=2; ei++){
            for(ll ej=-2; ej<=2; ej++){
                int nx = x+ei;
                int ny = y+ej;
                // 移動すると範囲外になったり、#だったり、探索済みだったら終了する
                if(nx < 0 || nx >= H || ny < 0 || ny >= W
                    || v[nx][ny] <= s+1 || S[nx][ny] == '#') continue;
                // 未探索だったら、キューに入れて現在の距離を記録
                que.emplace_back(nx, ny);
                v[nx][ny] = s+1;
            }
        }
    }

    // REP(i, H){
    //     REP(j, W){
    //         cout << i << ":" << j << ":" << v[i][j] << endl;
    //     }
    // }
    ll ans = v[gx][gy];
    if(ans == LINF) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13492
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
// #define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	string s;
	cin >> s;
	if (islower(s[0])) {
		cout << "a\n";
	} else {
		cout << "A\n";
	}
 	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if (a==b && b==c) cout<<'1';
	else if (a==b && b!=c) cout<<'2';
	else if (a==c && b!=c) cout<<'2';
	else if (c==b && a!=c) cout<<'2';
	else cout<<'3';
}

Measured memory_bytes: 256
number_of_observatory, number_of_road = map(int, input().split())
height_list = [0]  # 1始まりで合わせるため
height_list.extend(list(map(int, input().split())))

road_list = []
for i in range(number_of_road):
    li = list(map(int, input().split()))
    road_list.append(li)  # start・end の順に格納
counta = 0

not_good_list = []
# 良い展望台でない展望台をリストに詰める
for road in road_list:
    if height_list[road[0]] < height_list[road[1]]:
        not_good_list.append(road[0])
    elif height_list[road[0]] > height_list[road[1]]:
        not_good_list.append(road[1])
    else:
        not_good_list.extend(road)

not_good_set = set(not_good_list)
observatory_set = set(range(1, number_of_observatory+1))

print(len(observatory_set - not_good_set))


Measured memory_bytes: 44408
$d, $g = gets.split.map(&:to_i)
$pc = []
$d.times do
  $pc.push gets.split.map(&:to_i)
end

Inf = 10**9

$dfsh = Hash.new

def dfs(sum, sp)
  return 0 if sum >= $g
  return $dfsh[[sum, sp]] if $dfsh[[sum, sp]]

  min_c = Inf
  0.upto($d - 1) do |i|
    nsp = sp.dup
    sum_i = sum
    next if sp[i] == $pc[i].first

    remain = $g - sum
    take = [remain / ((i + 1) * 100), $pc[i].first].min
    take = 1 if take.zero?
    if take == $pc[i].first
      sum_i += (i + 1) * 100 * take + $pc[i].last
      if sum_i >= $g
        s = take
      else
        nsp[i] = take
        s = take + dfs(sum_i, nsp)
      end
    else
      s = take
    end
    min_c = s if s < min_c
  end
  $dfsh[[sum,sp]] = min_c
end

sp = Array.new($d) { 0 }

puts dfs(0, sp)


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

#define ll long long  
#define endl "\n"

const ll int MOD=1e9+7;

void solve()
{
	ll a; double b;
	cin >> a >> b;
	int c = round(b*100);
	//cout << c << endl;
	cout << fixed;
	cout << (a*c)/100<< endl;
}

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

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
long long const MAX=1e12L+2;
long long dp[3002][3002]={0};
void initialize()
{long long i,j;
    for(i=0;i<3002;i++)
{for(j=0;j<3002;j++)
{dp[i][j]=0;}}
return;}
int main()
{long long i,j,x,n,r,k,p,w,y,sum,m;
initialize();
vector<char>v;
string s,t;
cin>>s>>t;
n=s.length();
m=t.length();
for(i=1;i<=n;i++)
{for(j=1;j<=m;j++)
{if(s[i-1]==t[j-1])
dp[i][j]=dp[i-1][j-1]+1;
else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);}}
v.push_back(' ');
i=n;j=m;
while(i>0&&j>0)
{if(dp[i][j]==dp[i][j-1])
{j=j-1;}
else if(dp[i][j]==dp[i-1][j])
{i=i-1;}
else {i=i-1;j=j-1;
v.push_back(s[i]);}
if(dp[i][j]==0)
break;}
for(i=v.size()-1;i>=0;i--)
{cout<<v[i];}

return 0;}


Measured memory_bytes: 70656
#include <stdio.h>
#include <string.h>
char s[10];
int a,w,t,r;
int main(){
	int n,i;
	scanf("%d",&n);
	while(n--){
		scanf("%s",s);
		if(s[0]=='A')a++;
		else if(s[0]=='W')w++;
		else if(s[0]=='T')t++;
		else if(s[0]=='R')r++;
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",w);
	printf("TLE x %d\n",t);
	printf("RE x %d\n",r);
	return 0;
}

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

int n, k;
int dp[100010], a[100010];

int isWin(int k) {
    int &y = dp[k];
    if(y!= -1) return y;
    y = 0;
    for(int i=1; i<=n; ++i) {
        if(a[i] <= k and !isWin(k-a[i])) {
            y = 1;
        }
    }
    return y;
}

int main() {
    memset(dp, -1, sizeof(dp));
	cin >> n >> k;
	for(int i=1; i<=n; ++i) {
	    cin >> a[i];
    }
	if(isWin(k)) {
	    cout<<"First\n";
	}
	else {
	    cout << "Second\n";
	}
	return 0;
}


Measured memory_bytes: 8676
# C
import functools
# 3.4以前は math の gcd が対応していないので fractions のものを使う
# from fractions import gcd
def gcd(a,b):
    if a<b:a,b=b,a
    if a%b==0:return b
    return gcd(b,a%b)


n = int(input())
a = list(map(int, input().split()))

gcd_left = [a[0]]
gcd_right = [a[-1]]
for i in range(1,n):
    if gcd_left[i-1] != 1:
        res = gcd(gcd_left[i-1], a[i])
    else:
        res = 1
    gcd_left.append(res)

for i in range(1,n):
    if gcd_right[i-1] != 1:
        res = gcd(gcd_right[i-1], a[-(i+1)])
    else:
        res = 1
    gcd_right.append(res)
gcd_right = gcd_right[::-1]


ans = 0
for i in range(n):
    if i == 0:
        res = gcd_right[1]
    elif i == n-1:
        res = gcd_left[-2]
    else:
        res = gcd(gcd_right[i+1], gcd_left[i-1])
    ans = max(res, ans)
print(ans)


Measured memory_bytes: 14576
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define MST(vv,x) memset(vv,x,sizeof(vv))
#define ll long long
#define maxn 30
int main()
{
    ll n,m,sum;
    ll s1[200010];
    while(scanf("%lld",&n)!=EOF)
    {
        sum=0;
        for(ll a=1; a<=n; a++)
        {
            cin>>s1[a];
            sum+=s1[a];
        }
        ll temp=0,mi=sum-s1[1]-s1[1];
        if(mi<0)mi=-mi;
        for(ll a=1; a<n; a++)
        {
            temp+=s1[a];
            ll num=sum-temp-temp;
            if(num<0)num=-num;
            if(num<mi)mi=num;
        }
        cout<<mi<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<pair<ll, pair<ll, ll>>> p(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(a+b, make_pair(a, b));
    }
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());

    ll taka = 0, aoki = 0;
    rep(i, n) {
        if(i%2 == 0) {
            taka += p[i].second.first;
        }
        else {
            aoki += p[i].second.second;
        }
    }

    cout << taka - aoki << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int tu[1000][1000];
int a[10000];
int d[10000];
int f[10000];
int shijian,n;
void sou(int u){
     a[u]=2;
     d[u]=++shijian;
     for(int i=0;i<n;i++){
        if(tu[u][i]==0) continue;
        if(a[i]==1) {
            sou(i);
        }
     }
     a[u]=3;
     f[u]=++shijian;
}
void shensou(){
     for(int u=0;u<n;u++){
        a[u]=1;
     }
     shijian=0;
     for(int u=0;u<n;u++){
        if(a[u]==1)sou(u);
     }
     for(int u=0;u<n;u++){
         printf("%d %d %d\n",u+1,d[u],f[u]);
     }
}


int main(){
   int v;
   int m;
   int x;
   scanf("%d",&n);
   for(int i=0;i<n;i++){
        scanf("%d%d",&v,&m);
        v--;
        for(int j=0;j<m;j++){
            scanf("%d",&x);
            x--;
            tu[v][x]=1;
        }
   }
   shensou();
return 0;
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,n) for(Int i=0;i<n;++i)
using namespace std;

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

    string S; cin >> S;
    Int numB = 0;
    Int numFlip = 0;

    rep(i, S.size()) {
        if (S[i] == 'W') numFlip += numB;
        else ++numB;
    }

    cout << numFlip << "\n";
}

Measured memory_bytes: 720
while True:
    n,x = map(int,input().split())
    if n+x == 0:
        break
    else:
        ans = 0
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                for k in range(j+1,n+1):
                    if i+j+k == x:
                        ans += 1
    print(ans)



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
  int n;
  int d[100100];

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

  sort(d, d+n);


  int a = (n-2)/2;
  int b = (n-2)/2 + 1;

  int ans = 0;
  if (d[a] == d[b]) {
    ans = 0;
    cout << ans << endl;
    return 0;
  }

  ans = d[b] - d[a];
  cout << ans << endl;
}


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

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      int N = Integer.parseInt(br.readLine());
      System.out.println(2*N*Math.PI);
    }catch(Exception e){
      System.out.println(e.toString());
    }
  }
}

Measured memory_bytes: 33036
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	v := make([]float64, n)
	for i := range v {
		fmt.Scan(&v[i])
	}

	for len(v) > 1 {
		sort.Float64s(v)
		x, y := v[0], v[1]
		v = append(v, (x+y)/2)
		v = v[2:]
	}

	fmt.Println(v[0])
}


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

int main() {
  int n;
  cin >> n;
  set<int> s;
  bool b=true;
  for(int i=0; i<n; i++) {
    int a;
    cin >> a;
    if(s.count(a)) b=false;
    s.insert(a);
  }
    
  if(b) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0; 
}

Measured memory_bytes: 9600
#include <stdio.h>
int main(int argc, char *argv[])
{
	int a;
	scanf("%d",&a);
	if(a<1200)
	{
		printf("ABC\n");
	}
	else if(a<2800)
	{
		printf("ARC\n");
	}
	else
	{
		printf("AGC\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}


signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b;
  rep(i, 7){
    cin >> a >> b;
    cout << a - b << '\n';
  }
  
  return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int INF = 10e+7;

typedef pair<int, int> P;

vector<int> G[100000];
int p_max[100000];
int p_min[100000];
int p_ans[100000];
int depth[100000];

void dfs_p(int v, int p){
    if(p_min[v] <= p-1) p_ans[v] = p-1;
    else p_ans[v] = p+1;
    for(int i = 0; i < G[v].size(); i++){
        if(depth[G[v][i]] > depth[v]) dfs_p(G[v][i], p_ans[v]);
    }
}
void dfs(int v, int d){
    depth[v] = d;
    for(int i = 0; i < G[v].size(); i++){
        if(depth[G[v][i]] == 0) dfs(G[v][i], d+1);
    }
}

int main(){
    int N, K;
    cin >> N;
    for(int i = 0; i < N; i++){
        p_max[i] = -INF;
        p_min[i] = INF;
    }
    for(int i = 0; i < N-1; i++){
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    cin >> K;
    int root = -1;
    for(int i = 0; i < K; i++){
        int V, P;
        cin >> V >> P;
        V--;
        p_max[V] = P;
        p_min[V] = P;
        if(root == -1) root = V;
    }
    dfs(root, 1);
    
    priority_queue<P> que;
    for(int i = 0; i < N; i++){
        que.push(P(depth[i], i));
    }
    while(!que.empty()){
        P top = que.top();
        que.pop();
        int idx = top.second;
        //cout << idx << ' ' << depth[idx] << endl;
        for(int i = 0; i < G[idx].size(); i++){
            if(depth[idx] > depth[G[idx][i]]){
                if(p_min[idx] == INF) continue;
                int par = G[idx][i];
                if(p_min[par] == INF){
                    p_min[par] = p_min[idx]-1;
                    p_max[par] = p_max[idx]+1;
                }else{
                    if(p_min[par] > p_max[idx]+1 || p_max[par] < p_min[idx]-1){
                        cout << "No" << endl;
                        return 0;
                    }else if(p_min[par]%2 !=  (p_min[idx]-1)%2){
                        cout << "No" << endl;
                        return 0;
                    }else{
                        p_min[par] = max(p_min[par] ,p_min[idx]-1);
                        p_max[par] = min(p_max[par] ,p_max[idx]+1);
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
    dfs_p(root, p_min[root]+1);
    for(int i = 0; i < N; i++){
        cout << p_ans[i] << endl;
    }
}  

Measured memory_bytes: 13556