akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
#define X real()
#define Y imag()
typedef long double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
D eps=1e-9;
D cro(P a,P b){return imag(conj(a)*b);}
inline int ccw(P a,P b,P c){
	if(cro(b-a,c-a)>eps) return 1;
	if(cro(b-a,c-a)<-eps) return -1;
	return 0;
}

bool iLSex(L l,L s){
	return cro(l.sc-l.fs,s.fs-l.fs)*cro(l.sc-l.fs,s.sc-l.fs)<-eps;
}
P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+t*(b.sc-b.fs);
}
Pol convexcut(Pol p,L l){
	Pol ret;
	rep(i,p.size()){
		if(ccw(l.fs,l.sc,p[i])!=-1) ret.pb(p[i]);
		L s=L(p[i],p[(i+1)%p.size()]);
		if(iLSex(l,s)) ret.pb(intLL(l,s));
	}
	return ret;
}
vector<Pol> makevoronoi(Pol vp,Pol pol){
	vector<Pol> ret;
	Pol polc=pol;
	rep(i,vp.size()){
		pol=polc;
		rep(j,vp.size()){
			if(i==j) continue;
			P p=(vp[i]+vp[j])/(long double)2.0,q=p+(vp[j]-vp[i])*P(0,1);
			pol=convexcut(pol,L(p,q));
		}
		ret.pb(pol);
	}
	return ret;
}
D aPol(Pol p){
	int n=p.size();
	D ret=0;
	rep(i,n) ret+=cro(p[i],p[(i+1)%n])/2;
	return ret;
}
int M,N;
Pol pol,vp;
D calc(D e,D f,D g,D h,D x){
	return e*x*x*x*x+f*x*x*x+g*x*x+h*x;
}
int main(){
	cin>>M>>N;
	rep(i,M){
		int x,y;
		cin>>x>>y;
		pol.pb(P(x,y));
	}
	rep(i,N){
		int x,y;
		cin>>x>>y;
		vp.pb(P(x,y));
	}
	vector<Pol> vor=makevoronoi(vp,pol);
	D sum=0;
	rep(i,N){
		Pol v=vor[i];
		P o=vp[i];
		D tmp=0;
//		show(i);
//		rep(j,v.size()) cout<<j<<":"<<v[j]<<endl;
//		cout<<endl;
		rep(j,v.size()){
			P p=v[j],q=v[(j+1)%v.size()];
			if(abs(p.X-q.X)<eps) continue;
			D a=(p.Y-q.Y)/(p.X-q.X),b=p.Y-a*p.X;
			b+=a*o.X-o.Y;
			D c=-o.Y;
			D e=a+a*a*a/3,f=b-c+a*a*b,g=a*b*b,h=(b*b*b-c*c*c)/3;
			e/=4,f/=3,g/=2;
			D val=calc(e,f,g,h,p.X-o.X)-calc(e,f,g,h,q.X-o.X);
			tmp+=val;
		}
		sum+=tmp;
	}
	printf("%.12f\n",(double)sum/(double)aPol(pol));
}

Measured memory_bytes: 1268
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define print(x) printf("%d",x)
#define scan(x) scanf("%d",&x)
#define printn(x) printf("%d\n",x)
#define rep(i,n,m) for(int i = n; i < m; i++)

int main(void){
	int a[100];
	int n;
	int count = 0;
	int minj;
	int ex;
	scan(n);
	rep(i,0,n){
		scan(a[i]);
	}
	
	rep(i,0,n){
		minj = i;
		rep(j,i,n){
			if(a[minj] > a[j]){
				minj = j;
			}
		}
		if(a[i] != a[minj]) count++;
		ex = a[minj];
		a[minj] = a[i];
		a[i] = ex;
	}

	rep(i,0,n){
		print(a[i]);
		if(i != n-1){
			printf(" ");
		}
	}
	printf("\n");
	printn(count);
	return 0;
}


Measured memory_bytes: 2092
from fractions import gcd
n = int(input())
A = list(map(int, input().split()))

L = {}
R = {}

L[0] = A[0]
#print("L", 0, L[0])
for i in range(n-1):
  L[i+1] = gcd(L[i], A[i+1])
  #print("L", i+1, L[i+1])

R[n-1] = A[n-1]
#print("R", n-1, R[n-1])
for i in range(n-1):
  R[n-2-i] = gcd(R[n-1-i], A[n-2-i])
  #print("R", n-2-i, R[n-2-i])
  
max_gcd = 0
for i in range(1, n-1):
  max_gcd = max(gcd(L[i-1], R[i+1]), max_gcd)
  #print(i, L[i-1], R[i+1], gcd(L[i-1], R[i+1]))
max_gcd = max((max_gcd, L[n-2], R[1]))
print(max_gcd)

Measured memory_bytes: 107744
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

H = lines[0][0]
N = lines[0][1]
Elongate = 10005
Inf = 1000000000000

att = []
mag = []
for i in 1..N do
  att.push(lines[i][0])
  mag.push(lines[i][1])
end

dp = []
for i in 1..Elongate do
  dp.push(0)
end
for i in 1..H do
  dp.push(Inf)
end

for i in 1..H do
  for j in 1..N do
    new_dp = dp[Elongate - 1 + i - att[j-1]] + mag[j-1]
    if new_dp < dp[Elongate - 1 + i] then
      dp[Elongate - 1 + i] = new_dp
    end
  end
end

print dp[Elongate - 1 + H]


Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1000000007LL;
ll dp[105][4][4][4];


int main(){
  int N;
  cin >> N;
  
  rep(i,4){
    rep(j,4){
      rep(k,4){
        if(i==0 && j==2 && k==1) continue;
        {
          int a = i, b = j, c = k;
          swap(a,b);
          if(a==0 && b==2 && c==1) continue;
        }
        {
          int a = i, b = j, c = k;
          swap(b,c);
          if(a==0 && b==2 && c==1) continue;
        }        
        dp[2][i][j][k] = 1;
      }
    }
  }

  REP(i,2,N){
    rep(a,4){
      rep(b,4){
        rep(c,4){
          rep(x,4){
            if(b==0 && c==2 && x==1) continue;
            {
              int aa = a, bb = b, cc = c, dd = x;
              swap(aa,bb);
              if(aa==0 && bb==2 && cc==1) continue;
              if(bb==0 && cc==2 && dd==1) continue;
            }
            {
              int aa = a, bb = b, cc = c, dd = x;
              swap(bb,cc);
              if(aa==0 && bb==2 && cc==1) continue;
              if(bb==0 && cc==2 && dd==1) continue;
            }
            {
              int aa = a, bb = b, cc = c, dd = x;
              swap(cc,dd);
              if(aa==0 && bb==2 && cc==1) continue;
              if(bb==0 && cc==2 && dd==1) continue;
            }
            dp[i+1][b][c][x] += dp[i][a][b][c];
            dp[i+1][b][c][x] %= MOD;
          }
        }
      }
    }
  }

  ll ret = 0;
  rep(i,4){
    rep(j,4){
      rep(k,4){
        ret += dp[N-1][i][j][k];
        ret %= MOD;
      }
    }
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,k;
    cin >> n >> k;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) a[i] = (a[i] - 1) % k;
    VLL ru(n+1);
    REP(i,0,n) ru[i+1] = (ru[i] + a[i]) % k;
    LL ans = 0;
    map<LL,int> m;
    REP(i,0,n+1) {
        if (i >= k) m[ru[i-k]]--;
        ans += m[ru[i]];
        m[ru[i]]++;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 15872
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

mod = 10**9+7
n = int(input())
g = [[] for _ in range(n)]

for _ in range(n-1):
    x, y = map(int, input().split())
    g[x-1].append(y-1)
    g[y-1].append(x-1)

white = [0 for _ in range(n)]
black = [0 for _ in range(n)]


def dfs(v):
    tmp_w = 1
    tmp_b = 1
    if len(g[v]) == 0:
        white[v] = 1
        black[v] = 1
        return None
    for w in g[v]:
        g[w].remove(v)
        dfs(w)
        tmp_w *= white[w]+black[w]
        tmp_b *= white[w]
        tmp_w %= mod
        tmp_b %= mod
    white[v] = tmp_w
    black[v] = tmp_b
    return None


dfs(0)

print((white[0]+black[0]) % mod)


Measured memory_bytes: 101484
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

bool eq(const double x, const double y) {
    return abs(x - y) < 1e-8;
}

struct node {
    string name;
    int timeA;
    int income;
    node(string &L, int P, int A, int B, int C, int D, int E, int F, int S, int M) :
        name(L), income(F * S * M - P), timeA(A + B + C + (D + E) * M) { }

    bool operator <(const node& x) const {
        double l = 1.0 * income / timeA;
        double r = 1.0 * x.income / x.timeA;
        if(eq(l, r)) return name < x.name;
        else return l > r;
    }
};

int main() {
    for(int N; cin >> N, N; ) {
        vector<node> X;
        for(int i = 0; i < N; i++) {
            string L;
            int P, A, B, C, D, E, F, S, M;
            cin >> L;
            cin >> P >> A >> B >> C >> D >> E >> F >> S >> M;
            X.push_back(node(L, P, A, B, C, D, E, F, S, M));
        }
        sort(X.begin(), X.end());
        for(int i = 0; i < N; i++) {
            cout << X[i].name << endl;
        }
        cout << '#' << endl;
    }
}

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

int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  h = h * 30 + m * 0.5;
  m *= 6;
  long double deg = abs(m - h);
  if (deg == 180) {
    cout << fixed << setprecision(20) << a + b << endl;
    return 0;
  } else if (deg > 180) {
    deg = 360 - deg;
  }
  
  if (deg == 90) {
    cout << fixed << setprecision(20) << sqrt(a*a + b*b) << endl;
    return 0;
  }
  
  deg = cos(deg * M_PI / 180);
  long double ans = sqrt(a*a + b*b - 2*a*b*deg);
  cout << fixed << setprecision(20) << ans << endl;
}

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

int main() {

int x,n;
cin>>x>>n;

if(n==0)
{
	cout<<x;
	return 0;
}

vector<int> v;
for(int i=0;i<n;i++)
{
	int y;
	cin>>y;
	v.push_back(y);
}


for(int i=0;i<105;i++)
{
	if(count(v.begin(),v.end(),x-i)==0)
	{
		cout<<x-i;
		return 0;
	}
	else if(count(v.begin(),v.end(),x+i)==0)
	{
		cout<<x+i;
		return 0;
	}
}

	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int hb(int a,int t)
{
     if(a==t) return 1;
     else return 0;
}

int main(void)
{
     int a1, a2, a3, a4, b1, b2, b3, b4, t, h, b, i;
     
     while(0<1){
	  if(scanf("%d", &a1)==-1) break;
	  scanf("%d", &a2);
	  scanf("%d", &a3);
	  scanf("%d", &a4);
	  scanf("%d", &b1);
	  scanf("%d", &b2);
	  scanf("%d", &b3);
	  scanf("%d", &b4);
	   
	  h = 0;
	  b = 0;

	  h = h + hb(a1,b1);
	  h = h + hb(a2,b2);
	  h = h + hb(a3,b3);
	  h = h + hb(a4,b4);

	  if(b1==a2 || b1==a3 || b1==a4) b++;
	  if(b2==a1 || b2==a3 || b2==a4) b++;
	  if(b3==a1 || b3==a2 || b3==a4) b++;
	  if(b4==a1 || b4==a2 || b4==a3) b++;
	  
	  printf("%d %d\n", h, b);
     }

     return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int sort(const void *a, const void *b) {
 return *(double *)a - *(double *)b;
 }
int main(){
int a,b,c;
int x;
scanf("%d%d%d",&a,&b,&c);
x=a*100+b*10+c;
if(x%4==0){
	
	printf("YES\n");
}else{
	
	printf("NO\n");
	
}
	return 0;
	
	
	
}

Measured memory_bytes: 128
use std::io::stdin;

macro_rules! read {
    ($t: ty) => {{
        let mut line = String::new();
        stdin().read_line(&mut line);
        line.trim().parse::<$t>().unwrap()
    }};
    ($($t: ty), *) => {{
        let mut line = String::new();
        stdin().read_line(&mut line);
        let mut iter = line.split_whitespace();
        (
            $(iter.next().unwrap().parse::<$t>().unwrap(), )*
        )
    }}
}
macro_rules! reads {
    ($e:expr, $t:ty) => {{
        let mut v = vec![];
        for _ in 0..$e {
            let mut line = String::new();
            stdin().read_line(&mut line);
            v.push(line.trim().parse::<$t>().unwrap());
        }
        v
    }};
}

fn main() {
    let s = read!(String);
    let mut n = s.chars()
        .map(|x| if x == '0' { 0 } else { 1 })
        .collect::<Vec<_>>();

    let mut m = 0;
    let mut i = 0;
    while n.len() > i + 1 {
        let a = n[i];
        let b = n[i + 1];
        if a != b {
            n.remove(i);
            n.remove(i);
            i = if i > 0 { i - 1 } else { 0 };
            m = m + 2;
        } else {
            i = i + 1;
        }
    }
    println!("{}", m);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

// 1

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

    int i, a, b, n, s, f;
    cin >> a >> b >> n;
    rep(i, n){
        cin >> s >> f;
        if(a < f && b > s){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main(){
	for(int n, m, a; cin >> n >> m >> a, n;){
		vector<pair<int, pair<int, int> > > data;
		for(int i = 0; i < m; i++){
			int h, p, q; cin >> h >> p >> q;
			data.push_back(make_pair(h, make_pair(p, q)));	
		}
		sort(data.begin(), data.end());
		vector<int> l;
		for(int i = 0; i < n; i++){l.push_back(i + 1);}
		for(int i = 0; i < m; i++){
			int p = data[i].second.first;
			int q = data[i].second.second;
			int tmp = l[p - 1];
			l[p - 1] = l[q - 1];
			l[q - 1] = tmp;
		}
		cout << l[a - 1] << endl;
	}
	return 0;
}

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

int main(void)
{
  int a, b;
  cin >> a >> b;
  
  if (a<b){
    for (int i=0;i<b;i++){
      cout << a;
    }
  }else {
    for (int j=0;j<a;j++){
      cout << b;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
//#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

int main() {
    int a, b;
    cin >> a >> b;
    if (a == 1)
        a = 14;
    if (b == 1)
        b = 14;
    if (a == b)
        cout << "Draw\n";
    else
        if (a < b)
            cout << "Bob\n";
        else
            cout << "Alice\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
count = 0
while True:
    for tmp in range(N):
        if h[tmp] != 0:
            break
    else:
        break
    for i in range(tmp, N):
        if h[i] == 0:
            break
        else:
            h[i] = h[i] - 1
    count += 1
# tmp = h
# if len(set(tmp)) == 1:
print(count)


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

int main(void) {
    string T;
    cin >> T;
    for(int i=0;i<T.size();i++) {
        if(T[i] == '?') {
            T[i] = 'D';
        }
    }

    cout << T << endl;
    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;

ld ans = LLONG_MAX;
ll n;
vector <com> coor;

ld check(com t){
	ld temp = 0;
	for (int z=0;z<n;z++){
		temp = max(temp,norm(coor[z]-t));
	}
	ans = min(ans,temp);
	return temp;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	coor.resize(n);
	for (int z=0;z<n;z++){
		ld real,img;
		cin >> real >> img;
		com t(real,img);
		coor[z] = t;
	}
	ld xl = 0;
	ld xr = 1000;
	ld e = 1e-9;
	while (xr - xl >= e){
		ld l1 = xl + (xr-xl)/ld(3.0);
		ld r1 = xr - (xr-xl)/ld(3.0);
		ld yl = 0;
		ld yr = 1000;
		ld q1 = LLONG_MAX;
		ld q2 = LLONG_MAX;
		while (yr - yl >= e){
			ld l2 = yl + (yr-yl)/ld(3.0);
			ld r2 = yr - (yr-yl)/ld(3.0);
			com t(l1,l2);
			com t1(l1,r2);
			ld temp1 = check(t);
			ld temp2 = check(t1);
			q1 = min(temp1,temp2);
			if (temp1 < temp2){
				yr = r2;
			} else {
				yl = l2;
			}
		}
		yl = 0;
		yr = 1000;
		while (yr - yl >= e){
			ld l2 = yl + (yr-yl)/ld(3.0);
			ld r2 = yr - (yr-yl)/ld(3.0);
			com t(r1,l2);
			com t1(r1,r2);
			ld temp1 = check(t);
			ld temp2 = check(t1);
			q2 = min(temp1,temp2);
			if (temp1 < temp2){
				yr = r2;	
			} else {
				yl = l2;			
			}
		}	
		if (q1 < q2){
			xr = r1;
		} else {
			xl = l1;
		}
	}
	cout << setprecision(60) << fixed << sqrtl(ans) << endl;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/abc152/tasks/abc152_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M;
  cin >> N >> M;

  if (N == M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  
  int a,b;
  int n;
  int dp[17][17];
  int x,y;
  
  
  while(1){

    cin >> a >> b;
    if( a == 0 && b == 0 )break;
    
    for( int i = 0 ; i <= a ; i++ ){
      for( int j = 0 ; j <= b ; j++ ){
	dp[i][j] = 0;
      } 
    }
    
    cin >> n;
    while(n--){
      cin >> x >> y;
      dp[x][y] = -1;
    }

    dp[1][1] = 1;

    for( int i = 1 ; i <= a ; i++ ){
      for( int j = 1 ; j <= b ; j++ ){
	if( i == 1 && j == 1 ) continue;
	if( dp[i][j] == -1 ){
	  dp[i][j] = 0;
	  continue;
	}
	dp[i][j] = dp[ i - 1 ][j] + dp[i][ j - 1 ];
      }
    }
    cout << dp[a][b] << endl;
  }
  return 0;
}

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

int main(){
    int g = 0;
    int n,x;
    cin>>n>>x;
    rep(i,n){
        int v;
        cin>>v;
        v-=x;
        g=__gcd(g,abs(v));
    }
    cout<<g<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) cin >> A[i];
    vll S(N + 1);
    REP(i, 1, N + 1) {
        S[i] = S[i - 1] + A[i - 1];
    }
    vint L(N + 1), R(N + 1);
    L[1] = 1;
    R[1] = 3;
    ll ans = LINF;
    REP(i, 2, N - 1) {
        ll minSUBL = LINF;
        REP(j, L[i - 1], i) {
            if (minSUBL >= abs((S[j] - S[0]) - (S[i] - S[j]))) {
                minSUBL = abs((S[j] - S[0]) - (S[i] - S[j]));
                L[i] = j;
            }
            else {
                break;
            }
        }
        ll minSUBR = LINF;
        REP(j, R[i - 1], N) {
            if (minSUBR >= abs((S[j] - S[i]) - (S[N] - S[j]))) {
                minSUBR = abs((S[j] - S[i]) - (S[N] - S[j]));
                R[i] = j;
            }
            else {
                break;
            }
        } 

        ll p, q, r, s;
        p = S[L[i]];
        q = S[i] - S[L[i]];
        r = S[R[i]] - S[i];
        s = S[N] - S[R[i]];
        ans = min(ans, max(max(max(p, q), r), s) - min(min(min(p, q), r), s));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int lli;
    #define MAX 200005
    #define INF 1000005
    #define endl "\n"
    lli arr[MAX];
    lli f[INF];
    bool p[INF];
    bool flag[MAX];
    int main(){
    	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
    	lli n;
    	cin>>n;
    	for(lli i = 0; i<n; i++){
    		cin>>arr[i];
    		f[arr[i]]++;
    	}
    	lli c = 0;
    	bool flag = false;
    	for(lli i = 0; i<n; i++){
    		flag = false;
    		f[arr[i]]--;
    
    		for(lli j = 1; j*j <= arr[i]; j++){
    			if(arr[i]%j == 0){
    				if(f[j] || f[arr[i]/j]){
    					flag = true;
    					break;
    				}
    			}
    		}
    		if(!flag){
    			c++;
    		}
    		f[arr[i]]++;
    	}
    	cout<<c<<endl;
    	
    }

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

# define ll long long



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
    ll ans=n+ n*n + n*n*n;
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3648
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();	
        int[] array = new int[200];
        for(int i = 0 ; i < n ; i ++){
          array[i] = sc.nextInt();
        }
      	int count = 0;
      	boolean flg = true;
      while(flg){
      	for(int i = 0 ; i < n ; i++){
        	if(array[i] % 2 != 0){
            	flg = false;
              break;
            }
          	array[i] /= 2;
        }
        if(!flg) {
        	break;
        }
      	count ++;
      }
      
System.out.print(count);


    }
}


Measured memory_bytes: 36216
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main()
{
	int x,y;
	cin >> x >> y;
	if (x % y == 0)
		puts("-1");
	else
		cout << x << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int H , N ;
    cin >> H >> N ;

    int ans = 0;
    int a;
    for(int i = 0; i < N ; i++) {
        cin >> a;
        ans += a ;

    }

    if(ans>=H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
	int N;
	double A;
	double bunnbo = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		bunnbo += (1 / A);
	}
	double answer;
	answer = 1 / bunnbo;
	cout << answer << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	int n, ans = 0;
	cin >> n;
	
	for (int i = 1; i <= n; i += 2) {
		int div = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) div++;
		}
		if (div == 8) ans++;
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 2005;
const int mod = 1e9 + 7; 
using namespace std;

int n, m, f[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> (); 
	f[n + 1] = 1; 
	for(int i = 1; i <= m; i++)
		for(int j = n; j; j--)
		{
			if(n - j + 1 < i) f[j] = 0; 
			else f[j] = (f[j] + f[j + 1]) % mod; 
		}
	if(n != m) f[1] = 1ll * f[1] * fpow(2, n - m - 1) % mod; 
	printf("%d\n", f[1]); 
	return 0; 
}


Measured memory_bytes: 3228
N = int(input())
A = [int(x) for x in input().split()]

correct = []
if N & 1:
    correct.append(0)
    for i in range(2, N//2 * 2 + 1, 2):
        correct.append(i)
        correct.append(i)
else:
    for i in range(1, N//2 * 2, 2):
        correct.append(i)
        correct.append(i)
print(pow(2, N//2,  int(1e9) + 7) if sorted(A) == correct else 0)

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

string t1,t2;

int ans=0;

void dfs(int idx1,int idx2,int cnt){

  ans=max(ans,cnt);
  
  if(idx1==t1.size()) return ;
  if(idx2==t2.size()) return ;
  
  if(t1[idx1]==t2[idx2]) dfs(idx1+1,idx2+1,cnt+2);

  dfs(idx1+1,idx2,cnt);
  
  dfs(idx1,idx2+1,cnt);
  
}

int main(){

  string s;
  
  cin>>s;


  int f=0;
  for(int i=0;i<s.size();i++){

    if(s[i]=='w') f=1;
    else if(!f) t1+=s[i];
    else t2+=s[i];
    
  }

  for(int i=0;i<t2.size();i++){
    if(t2[i]=='(') t2[i]=')';
    else if(t2[i]==')') t2[i]='(';
    else if(t2[i]=='{') t2[i]='}';
    else if(t2[i]=='}') t2[i]='{';
    else if(t2[i]=='[') t2[i]=']';
    else if(t2[i]==']') t2[i]='[';
  }

  reverse(t2.begin(),t2.end());
  
  dfs(0,0,1);

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

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e15
//#define mx 1000005
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll int a,ans;
    cin>>a;
    ans=a+a*a+a*a*a;
    cout<<ans;
    return 0;
}


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

#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))

int main()
{
	char S[100];
	int len = 0;

	scanf("%s", S);

	for (int i = 0; S[i] != '\0'; i++)
		len++;

	int count = 0;

	for(int i = 0; i < len/2; i++)
	{
		if (S[i] != S[len - i-1])
			count++;
	}
//	printf("%d\n", len);

	printf("%d", count);
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		string S = GetString();
		var num = new Dictionary<char, int>();
		for(int i = 0; i < S.Length; i++)
		{
			int c = 0;
			num.TryGetValue(S[i], out c);
			num[S[i]] = c + 1;
		}

		foreach(char key in num.Keys)
		{
			if(num[key] != 2)
			{
				Console.WriteLine("No");
				return;
			}
		}
		Console.WriteLine("Yes");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < (n);i++)
#define lint long long
const lint mod=1e9+7;
const lint inf=2.19e15+1;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

lint r,c,k;
lint fld[3050][3050];
lint dp[3050][3050][5];
lint maxi = -100000;


signed main(){
  cin >> r >> c >> k;
  REP(i, k){
    lint x,y,z;
    cin >> x >> y >> z;
    fld[x-1][y-1] = z;
  }
  dp[0][0][1] = fld[0][0];
  REP(i, r){
      REP(j, c){
          REP(k, 4){
              chmax(dp[i+1][j][0], dp[i][j][k]);
              
              chmax(dp[i+1][j][1], dp[i][j][k] + fld[i+1][j]);
              
              chmax(dp[i][j+1][k], dp[i][j][k]);

              chmax(dp[i][j+1][k + 1], dp[i][j][k] + fld[i][j+1]);

              if (i == r-1 and j == c-1){
                  chmax(maxi, dp[i][j][k]);
              }
          }
      }
  }
  chmax(maxi, dp[r-1][c-1][3]);
  chmax(maxi, dp[r-1][c-1][2]);
  chmax(maxi, dp[r-1][c-1][1]);
  chmax(maxi, dp[r-1][c-1][0]);
  cout << maxi << endl;
}

Measured memory_bytes: 432580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct Mat{
    mint val[50][50];
    Mat(){
        rep(i,50){
            rep(j,50){
                val[i][j]=0;
            }
        }
    }
};
Mat I;
Mat operator*(Mat a,Mat b){
    Mat c;
    rep(i,50){
        rep(j,50){
            rep(k,50){
                c.val[i][j]+=a.val[i][k]*b.val[k][j];
            }
        }
    }
    return c;
}
Mat matrix_power(Mat A,ll k){
    if(k==0)return I;
    Mat res=matrix_power(A,k/2);
    res=res*res;
    if(k%2==1)res=res*A;
    return res;
}
ll n,k;
int main(){
    cin>>n>>k;
    rep(i,50)I.val[i][i]=1;
    Mat A;
    rep(i,n){
        rep(j,n){
            cin>>A.val[i][j].x;
        }
    }
    Mat A_k=matrix_power(A,k);
    mint ans=0;
    rep(i,n){
        rep(j,n){
            ans+=A_k.val[i][j];
        }
    }
    cout<<ans.x<<endl;
    return 0;
}

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


int find_AB(int n) {
  int res = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i * i < n) {
        res += 2;
        continue;
      }
      
      if (i * i == n) {
        res++;
      }
      
      
    }
  } 
  
  return res;
}

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i = 1; i < N; i++) {
    ans += find_AB(N-i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD=998244353;

ll modpow(ll x,ll y){
  long long ans=1;
  while(y>0){
    if(y&1){
      ans*=x%MOD;
    }
    x*=x%MOD;
    x%=MOD;
    ans%=MOD;
    y>>=1;
  }
  return ans;
}

int main() {
  ll N;
  
  cin>>N;
  ll D[N+10];
  for(int i=0;i<N+10;i++){
    D[i]=0;
  }
  ll as;
  for(int i=0;i<N;i++){
    ll a;
    cin>>a;
    D[a]++;
    if(i==0){
      as=a;
    }
  }
  ll ans=1;
  ll cnt=1;
  for(int i=1;i<N+10;i++){
    if(D[i-1]==0){
      break;
    }
    ans*=modpow(D[i-1],D[i]);
    ans%=MOD;
    cnt+=D[i];
  }
  if(cnt!=N||as!=0||D[0]!=1){
    ans=0;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String k = stdIn.nextLine();
		k = k.toUpperCase();
		System.out.println(k);
	}

}

Measured memory_bytes: 17116
# coding: utf-8
# Your code here!
from operator import itemgetter

str = input()
nm=[int(x) for x in str.split(' ')]
n = nm[0]
m = nm[1]
ab_2d = []
for i in range( 0, m ):
    str_ab = input()
    ab = [int(x) for x in str_ab.split(' ')]
    ab_2d.append(ab)

sorted_ab_2d = sorted(ab_2d, key = itemgetter(1))

bridge = 0
count = 0

for i in range( 0, m ):
    if(sorted_ab_2d[i][0] > bridge):
        count = count + 1
        bridge = sorted_ab_2d[i][1] - 1
    # print('bridge',bridge)

print(count)

Measured memory_bytes: 23720
# -*- coding: utf-8 -*-
k,n=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
i=a[0]
l=0 # 最大距離
for j in a[1:]:
  if l < j-i: # j-1とjの距離
    l = j-i
  i=j
if l < a[0]+k-a[-1]:
  l=a[0]+k-a[-1]
print(k-l)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n;
    cin >> n;
    vi a(n);
    map<int, int> m;
    rep(i, n) {
        cin >> a[i];
        m[a[i]]++;
    }
    priority_queue<int> pq;
    for (auto x : m) {
        if (x.second >= 2) pq.push(x.first);
    }
    if (pq.size() <= 1) {
        cout << 0 << endl;
    } else {
        ll x = pq.top();
        pq.pop();
        ll y = pq.top();
        pq.pop();
        if (m[x] >= 4) cout << x * x << endl;
        else cout << x * y << endl;
    }
}

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

typedef long long ll;
 
ll abss(ll n) {
	return n>0?n:0;
}
 
int main() {
	ll a, b, c;
	scanf("%lld%lld%lld",&a,&b,&c);
	if (a<c) {
		printf("%lld %lld",0,abss(a+b-c));
	}
	else printf("%lld %lld",a-c,b);
    return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];

  vector<pair<int, int>> p(M);
  for(int i=0;i<M;i++) cin>>p[i].second>>p[i].first;
  sort(a.begin(),a.end());
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  int i=0,j=0,k=0;

  while(i<N&&j<M){
    if(a[i]<p[j].first){
      a[i]=p[j].first;
      k++;
    }
    if(k>p[j].second-1){
      j++;
      k=0;
    }
    i++;
    //cout<<i<<" "<<j<<" "<<k<<endl;
  }

  long ans =0;
  for(int i=0;i<N;i++){
     ans+=a[i];
    // cout<<a[i]<<endl;
   }
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<int> A(N);
    int sum = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    auto check = [&](int M){
        vec<int> B(N);
        for(int i=0;i<N;i++) B[i] = A[i]%M;
        sort(B.begin(),B.end());
//        cerr << M << "\n";
//        for(int i=0;i<N;i++) cerr << B[i] << (i!=N-1? " ":"\n");
        int l = 0,r = N-1;
        int c = 0;
        while(l<r){
            int a = B[l],b = M-B[r];
            if(a<b){
                B[r] += a;
                B[l] = 0;
                c += a;
                l++;
            }else if(a>b){
                B[l] -= b;
                B[r] = 0;
                c += b;
                r--;
            }else{
                c += a;
                B[l] = B[r] = 0;
                l++; r--;
            }
        }
        bool ok = true;
        for(int i=0;i<N;i++) ok &= B[i]==0;
        return ok && (c<=K);
    };

    int ans = 1;
    for(int i=1;i*i<=sum;i++) if(sum%i==0){
        if(check(i)) ans = max(ans,i);
        if(check(sum/i)) ans = max(ans,sum/i);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
num=list(map(int,input().split(" ")))
matrix=[list(map(int,input().split(" ")))for i in range(num[0])]
vector=[int(input())for i in range(num[1])]
ans=[]
for i in range(num[0]):
    ans.append(sum([(matrix[i][j]*vector[j])for j in range(num[1])]))
for i in ans:
    print(i)


Measured memory_bytes: 6024
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;

int main(){

    int N; cin >> N;

    long double n1 = double(N) / 3;
    cout << fixed;
    cout << setprecision(9) << n1 * n1 * n1 << endl;
    return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a=scan.nextInt();
        Dice[] dice=new Dice[a];
        int ans=-1;;
        int i=0,j=0;
        for(i=0;i<a;i++) {
        dice[i]=new Dice(scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt());
        }
        for(i=0;i<a;i++) {
        	for(j=1;j<a;j++) {
        		if(i != j) {
        		ans=dice[i].ans(dice[i], dice[j]);
        		}
        		if(ans==0) {
        			System.out.println("No");
        			break;
        		}
        	}
        	if(ans==0) {
        		break;
        	}
        }
        if(ans==1) {
        	System.out.println("Yes");
        }
        
        scan.close();
    }
}

class Dice{
	int Top;	//1
	int S;		//2
	int N;		//5
	int W;		//4
	int E;		//3
	int Bo;		//6
	int tmp;
	
	Dice(int a,int b,int c,int d,int e,int f){
		Top=a;
		S=b;
		N=e;
		W=d;
		E=c;
		Bo=f;
	}
	
	void TrunS() {
		tmp=Top;
		Top=N;
		N=Bo;
		Bo=S;
		S=tmp;
	}void TrunN() {
		tmp=Top;
		Top=S;
		S=Bo;
		Bo=N;
		N=tmp;
	}void TrunW() {
		tmp=Top;
		Top=E;
		E=Bo;
		Bo=W;
		W=tmp;
	}void TrunE() {
		tmp=Top;
		Top=W;
		W=Bo;
		Bo=E;
		E=tmp;				//問題発生　723546  723586
	}
	int ans(Dice dice,Dice dice2) {		//DICEⅢの課題に対するメソッド
		int x=1;
		int count=0;
		if(dice.Top==dice2.W) {
			dice2.TrunE();
		}else if(dice.Top==dice2.N) {
			dice2.TrunS();
		}else if(dice.Top==dice2.E) {
			dice2.TrunW();
		}else if(dice.Top==dice2.S) {
			dice2.TrunN();
		}else if(dice.Top==dice2.Bo) {
			dice2.TrunS();
			dice2.TrunS();
		}else if(dice.Top==dice2.Top) {
			//何もしない
		}else {
			return x;
		}//ここでTop調整終了
		if(dice.Bo==dice2.Bo) {
			if(dice.S==dice2.N) {
				if(dice.E==dice2.W && dice.W==dice2.E) {
					x=0;
				}
			}else if(dice.S==dice2.S) {
				if(dice.E==dice2.E && dice.W==dice2.W && dice.N==dice2.N) {
					x=0;
				}
			}else if(dice.S==dice2.E) {
				if(dice.E==dice2.N && dice.W==dice2.S) {
					x=0;
				}
			}else if(dice.S==dice2.W) {
				if(dice.E==dice2.S && dice.W==dice2.N) {
					x=0;
					
				}
			}
			if(dice.Top==dice2.Top) {
				count++;
			}if(dice.S==dice2.S) {
				count++;
			}if(dice.W==dice2.W) {
				count++;
			}if(dice.N==dice2.N) {
				count++;
			}if(dice.E==dice2.E) {
				count++;
			}if(count ==5) {
				x=0;
			}
		}
	return x;
	}
}


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

int main(){
  int N; cin >> N;
  vector<int> v(N);
  rep(i,N){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  v.push_back(INF);
  int ans=0;
  rep(i,N-2){
    for(int j=i+1;j<N-1;j++){
      int l=j; int r=N+1;
      while(r-l!=1){
        int mid=(l+r)/2;
        if(abs(v[j]-v[i])<v[mid]&&v[mid]<v[i]+v[j]) l=mid;
        else r=mid;
      }
      ans+=l-j;
    }
  }
  cout << ans << endl;        
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

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

    int ans;

    pair<int,int> pos;
    pos.first = 1;
    pos.second = n;

    rep(i,m){
        int l,r; cin >> l >> r;

        if(pos.second < l){
            cout << 0 << endl;
            return 0;
        }

        if(r < pos.first){
            cout << 0 << endl;
            return 0;
        }

        pos.first = max(pos.first, l);
        pos.second = min(pos.second, r);

    }

    cout << pos.second-pos.first+1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		double r =(double)fr.nextInt() ;	r *= Math.PI ;	r *= 2.0 ;
 		op.println(r) ;	
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

Measured memory_bytes: 33192
package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func bordersInt(in_map [][]int, invalid int) [][]int{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]int, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]int, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func bordersString(in_map [][]string, invalid string) [][]string{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]string, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]string, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if b/a < c {
		fmt.Println(b/a)
	} else {
		fmt.Println(c)
	}
}

Measured memory_bytes: 640
n = int(input())
moji = input()
alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
new_moji = []
for i in range(len(moji)):
    new_moji.append(alphabet[alphabet.index(moji[i]) + n])
print("".join(new_moji))

Measured memory_bytes: 39152
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    K = int(input())
    S = input()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9992