akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    vector<int>cnt(1000001);
    for(int x : a) {
        if(cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        for(int i = x;i<=1000000;i += x) {
            cnt[i]++;
        }
    }
    int ans = 0;
    for(int x:a) {
        if(cnt[x] == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8020
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
const double pi = acos(-1) ;
int sum(int x){
    return x * ( x + 1) / 2;
}
int fix(int x){
    return (x % MOD + MOD) % MOD ;
}
signed main(){
    fastio
    int n , k ;
    cin >> n >> k ;
    // 0 1 2 3
    n++;
    int ans = 0 ;
    for(int i = k; i <= n; i++){
        int nix = sum(i - 1) ;
        int nax = sum(n - 1) - sum(n - i - 1) ;
        ans += nax - nix + 1;
        ans = fix(ans) ;
    }
    cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0;i<h;i++){
    cin >> s[i];
  }
  vector<vector<int>> l(h,vector<int>(w));
  vector<vector<int>> r(h,vector<int>(w));
  vector<vector<int>> u(h,vector<int>(w));
  vector<vector<int>> d(h,vector<int>(w));
  for(int i=0;i<h;i++){
    if(s[i][0]=='.'){
      l[i][0]=1;
    }
    for(int j=1;j<w;j++){
      if(s[i][j]=='#'){
        l[i][j]=0;
      }
      else{
        l[i][j]=l[i][j-1]+1;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(s[i][w-1]=='.'){
      r[i][w-1]=1;
    }
    for(int j=w-2;j>=0;j--){
      if(s[i][j]=='#'){
        r[i][j]=0;
      }
      else{
        r[i][j]=r[i][j+1]+1;
      }
    }
  }
  for(int i=0;i<w;i++){
    if(s[0][i]=='.'){
      u[0][i]=1;
    }
    for(int j=1;j<h;j++){
      if(s[j][i]=='#'){
        u[j][i]=0;
      }
      else{
        u[j][i]=u[j-1][i]+1;
      }
    }
  }
  for(int i=0;i<w;i++){
    if(s[h-1][i]=='.'){
      d[h-1][i]=1;
    }
    for(int j=h-2;j>=0;j--){
      if(s[j][i]=='#'){
        d[j][i]=0;
      }
      else{
        d[j][i]=d[j+1][i]+1;
      }
    }
  }
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
    }
  }
  cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    bool flag=true;
	
    for(int i=0; i<N; i++){
	cin >> h[i];
    }
    
    for(int i=N-1; i>0; i--){
	if(h[i] <h[i-1] && h[i]>=1)
	    h[i-1]--;	
    }
    h[0]--;
    
    for(int i=0; i<N-1; i++){
	if(h[i] >h[i+1]){
	    flag = false;
	}
    }
    
    cout << (flag? "Yes": "No") << endl;
}



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int H, W, N;
PII xs[18][500][500];

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

  cin >> H >> W >> N;
  REP(y,H) REP(x,W)
	cin >> xs[0][y][x];

  vector<PII> ps(N);
  REP(i,N) cin >> ps[i];

  for(int i=1;i<18;++i){
	REP(y,H) REP(x,W){
	  auto&& par = xs[i-1][y][x];
	  xs[i][y][x] = xs[i-1][par.FF][par.SS];
	}
  }

  bool no = true;
  set<PII> s;
  for(auto&& p: ps){
	PII np = xs[17][p.FF][p.SS];
	if(s.count(np)){
	  no = false;
	}
	s.insert(np);
  }
  if(no){
	cout << -1 << endl;
	return 0;
  }

  int ans = 0;
  vector<vector<PII>> db(H, vector<PII>(W));
  REP(y,H) REP(x,W) db[y][x] = MP(y,x);
  for(int i=17;i>=0;--i){
	bool excess = false;
	set<PII> s;
	for(auto&& p: ps){
	  PII np = db[p.FF][p.SS];
	  np = xs[i][np.FF][np.SS];
	  if(s.count(np)){
		excess = true;
		break;
	  }
	  s.insert(np);
	}
	if(!excess){
	  ans |= 1<<i;
	  REP(y,H) REP(x,W){
		PII p = db[y][x];
		db[y][x] = xs[i][p.FF][p.SS];
	  }
	}
  }
  cout << ans+1 << endl;

  return 0;
}

Measured memory_bytes: 51648
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

int main(){
    double N,K; cin >> N >> K;
    double p = 1/N;
    double ans = 0;
    FOR(i,1,N+1){
        double add = p;
        int twoTimes = 0;
        while(i*pow(2,twoTimes)<K){
            twoTimes++;
        }
        add *= 1/(double)(1<<twoTimes);
        ans += add;
    }
    printf("%.12lf\n",ans);
    rn 0;
}




// str.substr(start,length) .... read the full question
int mainB(){
    string S;
    cin >> S;
    int F2 = stoi(S.substr(0,2));
    int L2= stoi(S.substr(2,2));
    if (F2 > 0 && L2 > 0 && F2<=12&&L2<=12){
        cout << "AMBIGUOUS"; rn 0;
    }
    else if (F2<=12 && F2 > 0){
        cout << "MMYY"; rn 0;
    }
    else if (L2<=12&& L2 > 0){
        cout << "YYMM"; rn 0;
    }
    else{
        cout << "NA"; rn 0;
    }
    
    
    rn 0;
}

// tolower()
int mainA(){
    int N,K; string S;
    cin >> N >> K >> S;
    S[K-1] = tolower(S[K-1]);
    cout << S;
    rn 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  ll N, K; cin >> N >> K;
  cout << min(N % K, K - N % K) << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int X,T;

void solve(){
    cout << max(X - T,0) << endl;
}

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

    solve();
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	
	public static void main(String args[])throws Exception{
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int [] City1=new int[M];
		int [] City2=new int[M];
        int [] tag = new int [N];

		
		Map<Integer,Integer> map = new TreeMap<>();
	
		for(int i=0;i<M;i++) {
			City1[i]=sc.nextInt();
			City2[i]= sc.nextInt();
			map.put(City2[i], i);
			
		}
		
		int y=0;
		int z=0;
		for(Integer key : map.keySet()){
			y=map.get(key);
			z = City1[y];
			if(tag[z-1]!=0) {
				City2[y]=tag[z-1];
				tag[z-1]=tag[z-1]+1;
				}else{
					tag[z-1]=1;
					City2[y]=tag[z-1];
					tag[z-1]=tag[z-1]+1;
				}
	      }
		for(int i=0;i<M;i++) {
			System.out.println(String.format("%06d%06d", City1[i],City2[i]));
		}
		
		sc.close();
	}

}


Measured memory_bytes: 150844
#include <bits/stdc++.h>
#define sc(x) scanf("%d", &x)
#define pr(x) printf("%d\n", x)
#define lowbit(x) (x & -x)
#define ll long long
#define N 5010
#define memset(x) memset(x, 0, sizeof(x))
using namespace std;
ll n, m, a[N], st[N], num[N], b[210][N], igl[210][N], igr[210][N], ig[N][N], ans = 0;
int main()
{
	sc(n);
	sc(m);
	for (int i = 1; i < n; i++)
	{
		int x;
		sc(x);
		a[i + 1] = a[i] + x;
	}
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
	sc(b[j][i]);
	for (int i = 1; i <= m; i++)
	{
		int l = 0, r = 0;
		for (int j = 1; j <= n; j++)
		{
			while (l && b[i][j] > st[l]) l--;
			igl[i][j] = l ? num[l] + 1 : 1;
			st[++l] = b[i][j];
			num[l] = j;
		}
		for (int j = n; j; j--)
		{
			while (r && b[i][j] > st[r]) r--;
			igr[i][j] = r ? num[r] - 1 : n;
			st[++r] = b[i][j];
			num[r] = j;
		}
		for (int j = 1; j <= n; j++)
		{
			ig[igl[i][j]][j] += b[i][j];
			ig[igl[i][j]][igr[i][j] + 1] -= b[i][j];
			ig[j + 1][j] -= b[i][j];
			ig[j + 1][igr[i][j] + 1] += b[i][j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		ig[i][j] += ig[i][j - 1];
		for (int j = 1; j <= n; j++)
		ig[i][j] += ig[i - 1][j];
		for (int j = i; j <= n; j++)
		ans = max(ans, ig[i][j] - a[j] + a[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 220800
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[6];
	for(int i=1;i<=5;i++)
	cin>>a[i];
	
	for(int i=1;i<=5;i++)
	{
		if(a[i]==0)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
	
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  int a,b,c,tem;
  cin>>a>>b>>c;
  tem=b/a;
  if(tem>c)cout<<c<<endl;
  else cout<<tem<<endl;
}
void solveH()
{
  int a,b,c,tem,i;
  cin>>a>>b>>c;
  tem=min(a,b);
  vector<int>vec;
  for(i=1;i<=tem;i++)
  {
    if(a%i==0&&b%i==0)
    {
      vec.push_back(i);
    }
  }
  cout<<vec[vec.size()-c]<<endl;
}
void solveI()
{
  double t,x;
  cin>>t>>x;
  cout<<fixed<<setprecision(10)<<t/x<<endl;
}
void solveJ()
{
  int n,i;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  sort(ar,ar+n);
  int sum=0;
  for(i=0;i<n-1;i++)
  {
    sum=sum+ar[i];
  }
  if(ar[n-1]<sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
void solveK()
{
  int A,B,x,y;
  cin>>A>>B;
  x=max((A+B),(A-B));
  y=max(x,A*B);
  cout<<y<<endl;
}
void solveM()
{
  int i,j;
  char ar[3][3];
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
      cin>>ar[i][j];
    }
  }
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
      if(i==j)cout<<ar[i][j];
    }
  }
}
bool check(int n)
{
  int sum=0,t,tem=n;
  while(tem!=0)
  {
    t=tem%10;
    sum=sum*10+t;
    tem=tem/10;
  }
  if(sum==n)return 1;
  else return 0;
}
void solveN()
{
  int a,b,i;
  cin>>a>>b;
  int count=0;
  for(i=a;i<=b;i++)
  {
    if(check(i))count++;
  }
  cout<<count<<endl;
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
  // solveD();
// solveE();
 //solveF();
// solveG();
//solveH();
//solveI();
//solveJ();
//solveK();
//solveM();
solveN();
  return 0;
}

Measured memory_bytes: 3620
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    bool[long] A;
    foreach (i; 0 .. M)
        A[lread()] = true;
    auto dp = new long[](N + 2);
    dp[0] = 1;
    foreach (i; 0 .. N)
    {
        if (i + 1 !in A)
            dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
        if (i + 2 !in A)
            dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
    }
    // writeln(dp);
    writeln(dp[N]);
}


Measured memory_bytes: 7164
# Sum of 4 Integers

x = Array.new(51, 0)
i = j = k = l = 10
i.times{|i|j.times{|j|k.times{|k|l.times{|l|x[i+j+k+l] += 1 }}}}

while line = ARGF.gets do
	puts x[line.to_i]
end

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

#define INF 1e9

int main(){
  int n;
  cin >> n;
  int u, v;
  cin >> u >> v;
  u--; v--;
  vector< vector<int> > V(n);
  vector<int> t_c(n, INF);
  vector<int> a_c(n, INF);
  for(int i = 0 ; i < n-1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  t_c[u] = 0;
  a_c[v] = 0;
  queue<int> q;
  q.push(u);
  while(!q.empty()){
    int a = q.front();
    q.pop();
    for(auto k:V[a]){
      if(t_c[k] != INF) continue;
      q.push(k);
      t_c[k] = t_c[a]+1;
    }
  }

  q.push(v);
  while(!q.empty()){
    int a = q.front();
    q.pop();
    for(auto k:V[a]){
      if(a_c[k] != INF) continue;
      q.push(k);
      a_c[k] = a_c[a]+1;
    }
  }

  int maxi = 0;
  for(int i = 0; i < n; i++){
    if(a_c[i] - t_c[i] > 0){
      maxi = max(maxi, a_c[i]);
    }
  }

  cout << maxi-1 << endl;
}


Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	string Sin;
	string Scmp;
	int N;
	cin >> N >> Sin;

	Scmp = Sin;
	int maxCnt = 0;
	int renzokuCnt = 0;
	for (int j = 1; j < N; j++) {
		for (int i = 0; i < (N - j); i++) {
			if ((Scmp[i + j] == Sin[i])&&(renzokuCnt < j)) {
				renzokuCnt++;
			} else {
				if (maxCnt < renzokuCnt) {
					maxCnt = renzokuCnt;
				}
				renzokuCnt = 0;
			}
		}
		if (maxCnt < renzokuCnt) {
			maxCnt = renzokuCnt;
		}
		renzokuCnt = 0;
	}

	cout << maxCnt;

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <limits.h>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    int H;
    int W;
    
    vector<string> S;
    
    cin >> H;
    cin >> W;
    
    for ( int i = 0; i < H; i++ ) {
        string s;
        cin >> s;
        
        S.push_back(s);
    }
    
    for ( int i = 0; i < W+2; i++ ) {
        cout << "#";
    }
    cout << endl;
    
    for ( int i = 0; i < H; i++ ) {
        cout << "#" << S[i] << "#" << endl;
    }
    
    
    for ( int i = 0; i < W+2; i++ ) {
        cout << "#";
    }
    cout << endl;
    
    
    
    return 0;
}

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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<ll,ll>

const int maxn=1e5+10;
const ll maxN=1e18+10;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int a[10][10],dd[10][10];
  memset(a,0,sizeof(a));
  memset(dd,0,sizeof(dd));
  int n;
  cin >> n;
  FOR(i,1,n)
   if (i%10!=0) {
   	string s=to_string(i);
   	int so=s[0]-'0';
   	a[so][i%10]++;
   }
  ll ans=0;
  FOR(i,1,9)
  FOR(j,1,9) 
  if (dd[i][j]==0)
  {
  	if (i!=j) {
  		 ans+=a[i][j]*a[j][i]*2;
  		 dd[j][i]=1;
  	}
  	else ans+=a[i][j]*a[i][j];
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long a = sc.nextInt();
		char c = sc.next().toCharArray()[0];
		long b = sc.nextInt();
		if (c == '+') {
			System.out.println(a + b);
		} else {
			System.out.println(a - b);
		}
	}
}

Measured memory_bytes: 9172
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>

#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP

using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,M; cin>>N>>M;
  vector<pair<ll,ll>> edges(M); rep(i,M) {ll a,b; cin>>a>>b; a--; b--; edges[i]={a,b};}
  
  ll ans=0;
  rep(i,M){
    dsu uf(N);
    rep(j,M){
      if(i==j) continue;
      ll a,b; tie(a,b)=edges[j];
      uf.merge(a,b);
    }
    if(uf.groups().size()>1) ans++;
  }
  
  cout<<ans<<'\n';
  
  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;

int main(){
  vector<int> ar(5);
  for(int i = 0; i < 5; i ++)
    cin >> ar[i];
  for(int i = 0; i < 5; i ++)
    if(!ar[i])
      cout << i + 1;

}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAXN = 100010;

int n, m;
vi fo[MAXN];
bool used[MAXN];

deque<int> path;

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0;i < m;++i){
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    fo[a].pb(b), fo[b].pb(a);
  }

  path.pb(0), used[0] = true;

  while(true){
    int nxt = -1;
    for(int e : fo[path.back()])
      if(!used[e]) nxt = e;
    if(nxt >= 0)
      path.pb(nxt),
      used[nxt] = true;
    else break;
  }

  while(true){
    int nxt = -1;
    for(int e : fo[path[0]])
      if(!used[e]) nxt = e;
    if(nxt >= 0)
      path.push_front(nxt),
      used[nxt] = true;
    else break;
  }

  printf("%d\n", sz(path));
  for(int i = 0;i < sz(path);++i)
    printf("%d%c", path[i] + 1,
                   i + 1 == sz(path) ? '\n' : ' ');

  return 0;
}


Measured memory_bytes: 6784
def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a

def lcd(a,b):
	return a * b // gcd(a,b)

n = int(input())

if n == 1:
	ans = int(input())
else:
	ans = lcd(int(input()),int(input()))

	for i in range(n-2):
		m = int(input())
		ans = lcd(ans,m)
print(ans)

Measured memory_bytes: 3064
function gcd(arr) {
    var f = (a, b) => b ? f(b, a % b) : a
    var ans = arr[0]
    for (var i = 1; i < arr.length; i++) {
        ans = f(ans, arr[i]); 
    }
    return ans 
}

function main(arg) {
	var arg = arg.split("\n")
	arg = arg[1].split(" ").map(Number)

	arg.sort((a, b) => a - b)

	var result = gcd(arg)

	console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{
	int N,M;
	cin >> N >> M;
	vector<int> X(M);
	for(int i(0);i<M;++i){
		cin >> X[i];
	}
	if (N >= M){
		cout << 0 <<endl;
		return 0;
	}
	sort(X.begin(), X.end());
	vector<int> diff(M-1);
	for (int i(0);i<M-1;++i){
		diff[i] = X[i+1]-X[i];
	}
	sort(diff.begin(), diff.end());
	int ans = X[M-1] - X[0];
	for (int i(0);i<N-1;++i){
		ans -= diff[M-2-i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

template<class T>
void warshallFloyd(Matrix<T> &G){
	for(int k = 0;k < G.size();k++){
		for(int i = 0;i < G.size();i++){
			for(int j = 0;j < G.size();j++){
				if(G[i][k] == INF || G[k][j] == INF) continue;
				G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
			}
		}
	}
}

signed main(){
	int n,m,l;
	cin >> n >> m >> l;
	Matrix<int> G(n,vector<int>(n,INF)),G2 = G;
	for(int i = 0;i < m;i++){
		int a,b,c;
		cin >> a >> b >> c; a--;b--;
		chmin(G[a][b],c);
		chmin(G[b][a],c);
	}
	warshallFloyd(G);
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			if(G[i][j] <= l){
				chmin(G2[i][j],1ll);
				chmin(G2[j][i],1ll);
			}
		}
	}
	warshallFloyd(G2);
	int q;
	cin >> q;
	for(int i = 0;i < q;i++){
		int s,t;
		cin >> s >> t; s--;t--;
		if(G2[s][t] != INF) cout << G2[s][t] - 1 << endl;
		else cout << -1 << endl;
	}
}


Measured memory_bytes: 1920
N, A, B = list(map(int, input().split()))
min_v = 0
max_v = 0
ab = A + B
if N > ab:
    max_v = min(A, B)
else:
    min_v = ab - N
    max_v = min(A, B)

print('{} {}'.format(max_v, min_v))


Measured memory_bytes: 2940
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n , a , b;
string s;

int main(){
  cin >> n >> a >> b >> s;
  int A = 0 , B = 0;
  for(auto ch : s) {
    if(ch == 'c') {
      puts("No");
    } else if(ch == 'a') {
      if(A + B < a + b) {
        puts("Yes");
        A++;
      } else {
        puts("No");
      }
    } else {
      if(A + B < a + b && B < b) {
        puts("Yes");
        B++;
      } else {
        puts("No");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define vi vector<ll>
#define vvi vector<vi>
const ll mod = 1000000007LL;

#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pi pair<ll, ll>
#define ppi pair<ll, pi>
#define pb push_back
#define all(v) v.begin(), v.end()
const ll inf = 1e18;

#define cerr                                                                   \
  if (false)                                                                   \
  cerr
#define db(x) cerr << "\n" << (#x) << " is " << (x) << endl;
inline int max(int a, int32_t b) { return a > b ? a : b; }
inline int max(int32_t a, int b) { return a > b ? a : b; }
inline int min(int a, int32_t b) { return a < b ? a : b; }
inline int min(int32_t a, int b) { return a < b ? a : b; }
int d4_1[4] = {1, 0, -1, 0};
int d4_2[4] = {0, 1, 0, -1};
int d8_1[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int d8_2[8] = {0, -1, 1, 0, -1, 1, 1, -1};

ll seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll l = 0, ll r = 1e18) {
  return uniform_int_distribution<ll>(l, r)(rng);
}

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(10);

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif

  ll t = 1;
  // cin>>t;

  while (t--) {
    int a, b, n;
    cin >> a >> b >> n;
    int i;
    if (n >= b) {
      i = b - 1;
    } else {
      i = n;
    }
    int ans = floor(a * i / (b * 1.0)) - a * floor(i / (b * 1.0));
    cout << ans << "\n";
  }
}

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define int long long

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)2e5 + 7;

int n;
int a[N],b[N];
int sum,ans;

main () {
    cin >> n;

    for (int i = 1; i <= n; i ++)
        cin >> a[i];

    for (int i = 1; i <= n; i ++)
        cin >> b[i];

    for (int i = 0; i <= 28; i ++) {
        int t = (1 << i);
        vector <int> v,d;

        for (int i = 1; i <= n; i ++)
            v.pb(a[i] % (t * 2));

        for (int i = 1; i <= n; i ++)
            d.pb(b[i] % (t * 2));

        sort (v.begin(),v.end());
        sort (d.begin(),d.end());

        for (int i = 0; i < v.size(); i ++) {
            int posL = lower_bound(d.begin(),d.end(),t - v[i]) - d.begin();
            int posR = upper_bound(d.begin(),d.end(),2 * t - v[i] - 1) - d.begin();
            int psL = lower_bound(d.begin(),d.end(),3 * t - v[i]) - d.begin();
            int psR = upper_bound(d.begin(),d.end(),4 * t - v[i] - 1) - d.begin();
//            cout << t << " " << v[i] <<  " " << posL << " " << posR << " " << psL << " " << psR << endl;
            ans += (posR - posL + 1) % 2;
            ans += (psR - psL + 1) % 2;
        }
        if (ans % 2)
            sum += t;
        ans = 0;
    }
    cout << sum << endl;
}


Measured memory_bytes: 8568
#include <iostream>

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

using namespace std;

int main() {
    int n,k;
    string s;
    cin>>n>>k>>s;
    if(s[k-1]=='A')s[k-1]='a';
    else if(s[k-1]=='B')s[k-1]='b';
    else if(s[k-1]=='C')s[k-1]='c';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int N,i,j,k = 0,ans = 0;
  char S[50];
  char abc[3] = {'A','B','C'};

  scanf("%d",&N);
  scanf("%s",S);

  for(i = 0;i < N;i++){
    if(S[i] == 'A'){
      for(j = i;j < i + 3;j++){
	if(S[j] != abc[j - i]){
	  break;
	}
	k++;
      }
      if(k == 3){
	ans++;
      }
    }
    k = 0;
  }

  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	//	State() {}
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};


inline bool operator< ( const State& a, const State& b) {
	if( a.enemy == b.enemy )
		return a.budget > b.budget;
	return a.enemy < b.enemy;
}

inline bool operator> ( const State& a, const State& b) {
	if ( a.enemy == b.enemy )
		return a.budget < b.budget;
	return a.enemy > b.enemy;
}

priority_queue<State, vector<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
		int min = b;
		while ( itr != points[i].end() ) {
			if ( (*itr).second > min ) {
				min = (*itr).second;
			} else {
				(*itr).second = min;
			}
			itr++;
		}
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}
		
		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		priority_queue<State, vector<State>, greater<State> > empty;
		status = empty;

		ncheck[0] = 1;
		status.push(State(0,0,l));
		
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {

					if ( check( i ) ) {
						ncopy();
						add(i);
						
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

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

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

	int pts[2] = {};

	for( int i = 0; i < n; ++i ) {
		string c1, c2;
		cin >> c1 >> c2;

		if( c1 == c2 ) {
			pts[0] += 1;
			pts[1] += 1;
		}
		else {
			pts[c1 < c2] += 3;
		}
	}

	cout << pts[0] << ' ' << pts[1] << endl;
}



Measured memory_bytes: 3168
n = int(input())
arr = [0] + [int(x) for x in input().split()]

def exec(sign):
    a = [x for x in arr]
    res = 0

    x = 0
    for i in range(n):
        x += a[i]
        tmp = sign - (x + a[i+1])
        if sign < 0:
            tmp = min(tmp, 0)
        else:
            tmp = max(tmp, 0)
        res += abs(tmp)
        a[i+1] += tmp
        sign *= (-1)
    return res

print(min(exec(1), exec(-1)))


Measured memory_bytes: 14332
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

const int N = 1e5 + 10;
vector<int> a[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> color(n, -1);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  int odd = 0, even = 0, one = 0;
  for (int i = 0; i < n; ++i) {
    if (color[i] >= 0) continue;
    color[i] = 0;
    vector<int> Q;
    Q.push_back(i);
    bool found = false;
    for (int j = 0; j < Q.size(); ++j) {
      int u = Q[j];
      for (auto& v : a[u]) {
        if (color[v] < 0) {
          color[v] = 1 - color[u];
          Q.push_back(v);
        } else {
          if (color[v] == color[u]) found = true;
        }
      }
    }
    if (Q.size() == 1) {
      one++;
    } else if (found) {
      odd++;
    } else {
      even++;
    }
  }
  int64 ret = (int64)(n - one) * one * 2 + (int64)one * one;
  ret += 1LL * odd * odd + 2LL * odd * even + 2LL * even * even;
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 7804
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program 
{
    static void Main()
    {
        for (; ; )
        {
            int n = int.Parse(Console.ReadLine());
            int m = int.Parse(Console.ReadLine());

            if (n == 0)
                return;

            bool[,] friend = new bool[n + 1, n + 1];
            for (int i = 0; i < m; i++)
            {
                string[] input = Console.ReadLine().Split();
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);

                friend[a, b] = true;
                friend[b, a] = true;
            }

            bool[] friendfriend = new bool[n + 1];
            for (int i = 0; i < n + 1; i++)
            {
                if (friend[1, i] == true)
                {
                    friendfriend[i] = true;
                    for (int j = 2; j < n + 1; j++)
                    {
                        if (friend[i, j] == true)
                            friendfriend[j] = true;
                    }
                }
            }

            int answer = 0;
            for (int i = 2; i < n + 1; i++)
            {
                if (friendfriend[i] == true)
                    answer++;
            }
            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 6188
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>

using namespace std;

// mita

int main() {
    int n;
    cin >> n;
    vector<long> sum;
    long mind = 1000000000;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        long back = sum.size() > 0 ? sum.back() : 0;
        sum.push_back(back + a);
    }
    int dl = 0;
    int dr = 2;
    for (int k = 1; k < n - 2; k++) {
        long minl = min(sum[0], sum[k] - sum[0]);
        long maxl = max(sum[0], sum[k] - sum[0]);
        for (int l = dl; l < k; l++) {
            long ll = sum[l];
            long lr = sum[k] - sum[l];
            if (abs(ll - lr) < maxl - minl) {
                minl = min(ll, lr);
                maxl = max(ll, lr);
                dl = l;
            }
            if (ll > lr) break;
        }
        long minr = min(sum[k + 1] - sum[k], sum[n - 1] - sum[k + 1]);
        long maxr = max(sum[k + 1] - sum[k], sum[n - 1] - sum[k + 1]);
        for (int r = max(k + 1, dr); r < n - 1; r++) {
            long rl = sum[r] - sum[k];
            long rr = sum[n - 1] - sum[r];
            if (abs(rl - rr) < maxr - minr) {
                minr = min(rl, rr);
                maxr = max(rl, rr);
                dr = r;
            }
            if (rl > rr) break;
        }
        if (max(maxl, maxr) - min(minl, minr) < mind) {
            mind = max(maxl, maxr) - min(minl, minr);
        }
    }
    cout << mind << endl;
}


Measured memory_bytes: 2420
if __name__ == "__main__":
#    N = int(input())
#    A = []
#    B = []
#    C = []
#    D = []
#    for i in range(N):
#        buf1, buf2 = list(map(int, (input().split(' '))))
#        A.append(buf1)
#        B.append(buf2)
#    for i in range(N):
#        buf1, buf2 = list(map(int, (input().split(' '))))
#        C.append(buf1)
#        D.append(buf2)
#
#    def calc_dist(a, b, c, d):
#        return pow((pow((c - a), 2) + pow((d - b), 2)), 0.5)
#
#    A_dist_buf = {}
#    B_dist_buf = {}
#    for i in range(N):
#        a_key = str(A[i]) + '_' + str(B[i])
#        b_key = str(C[i]) + '_' + str(D[i])
#        A_dist_buf[a_key] = calc_dist(0, 0, A[i], B[i])
#        B_dist_buf[b_key] = calc_dist(0, 0, C[i], D[i])
#    A_dist = sorted(A_dist_buf.items(), key=lambda x: x[1], reverse=True)
#    B_dist = sorted(B_dist_buf.items(), key=lambda x: x[1], reverse=True)
##    print(A_dist)
##    print(B_dist)
#    A = []
#    B = []
#    C = []
#    D = []
#    for key,ele in A_dist:
#        A.append(key.split('_')[0])
#        B.append(key.split('_')[1])
#    for key,ele in B_dist:
#        C.append(key.split('_')[0])
#        D.append(key.split('_')[1])
#    ans1 = 0
#    for i in range(N):
#        for j in range(N):
#            if len(A) <= i or len(C) <= j:
#                break
#            if ((A[i] < C[j]) and (B[i] < D[j])):
##                print(A[i], B[i], C[j], D[j])
#                ans1 += 1
#                del C[j], D[j]
#                break
#    print(ans1)

    N = int(input())
    R = [list(map(int, input().split(" "))) for _ in range(N)]
    B = [list(map(int, input().split(" "))) for _ in range(N)]
    R.sort(key=lambda x: (x[1], x[0]), reverse=True)
    B.sort(key=lambda x: (x[0], x[1]))
    f = [0] * N

    pair = 0
    for b in B:
        for i, r in enumerate(R):
            if r[0] < b[0] and r[1] < b[1] and f[i] == 0:
                pair += 1
                f[i] = 1
                break

    print(pair)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

int main() {
    string w;cin >> w;
    int count[127] = {0};
    
    for(auto j:w){
        
        count[j]++;
    }
    
    bool f = true;
    
    for(auto i = 0; i<127;i++){
        
        if (count[i]%2 != 0) f = false;
        
    }
    
    if(f)cout<<"Yes" << endl;
    else cout <<"No" << endl;
    
    return 0;
}






Measured memory_bytes: 256
import java.util.Scanner;

class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if (a < b)
System.out.println("a < b");
else if(a > b)
System.out.println("a > b");
else
System.out.println("a == b");
}
}



Measured memory_bytes: 26224
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

const int MAX_N = 100010;

int par[MAX_N];
int Rank[MAX_N];
int sized;

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        Rank[i] = 0;
    }
    sized = n;
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    sized--;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (Rank[x] == Rank[y]) {
            Rank[x]++;
        }
    }
}
bool same(int x, int y) {
    return find(x) == find(y);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int X[100010], Y[100010], Z[100010];
    init(N);
    rep(i, M) {
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--; Y[i]--;
        unite(X[i], Y[i]);
    }
    cout << sized << endl;

    return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>  // ver2.2.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){  //  nCr (小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){  //  nCr (%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
int stpow(int n){  //  階乗(%MOD)
if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);  //  階乗配列(%MOD)
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  cout << n*n << endl;
  return 0;
}

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

int main()
{
	int f=1,i,j,n,a[100000][3];
	cin>>n;
	for(i=0;i<=n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if(a[i][2]+a[i][1]>a[i][0]||a[i][0]%2!=(a[i][1]+a[i][2])%2) 
			f=0;
	}
	if(f==1)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 1408