akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
template <typename T>
inline void read(T &x) {
	x = 0;
	T f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
inline void d_read(double &x) {
	x = 0.0;
	int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
	if (c == '.'){
		double num = 1.0;
		c = getchar();
		for (; isdigit(c); c = getchar()) x = x + (num /= 10) * (c ^ 48);
	}
	x *= f;
}

template <typename T>
inline void w(T x) {
	if (x > 9) w(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x, char c) {
	if (x < 0){
		putchar('-');
		x = -x;
	}
	w(x);
	putchar(c);
}

int a[200005], b[200005];
ll s1[200005], s2[2000005];
int main(){
	int n, m;
	ll k;
	read(n); read(m); read(k);
	for (int i = 1; i <= n; i ++) {
		read(a[i]);
		s1[i] = s1[i - 1] + a[i];
	}
	for (int i = 1; i <= m; i ++) {
		read(b[i]);
		s2[i] = s2[i - 1] + b[i];
	}
	int ans = 0;
	for (int i = 0; i <= n; i ++) {
		if (s1[i] > k) break;
		ll sum = k - s1[i];
		int l = 0, r = m, cnt = 0;
		while(l <= r) {
			int mid = l + r >> 1;
			if (s2[mid] <= sum) {
				l = mid + 1;
				cnt = mid;
			} 
			else r = mid - 1;
		}
		ans = max(ans, cnt + i);
	}
	write(ans, '\n');
	return 0;
}


Measured memory_bytes: 8324
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,ans[101],s;
int main()
{
 cin>>a>>b>>c;
 ans[a]++;
 ans[b]++;
 ans[c]++;
 for(int i=1;i<=100;i++)
 {
 	if(ans[i]>0) s++;
 }
 cout<<s;
 return 0;
}


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

const int INF = 1<<29;

bool doit(){
	int N;
	map<string, int> points;
	map<int, set<string> > present;

	cin >> N;
	if(N == 0){
		return false;
	}

	for(int i=0; i<N; i++){
		string name;
		int M;
		cin.ignore();
		cin >> name >> M;

		points[name] = 0;

		for(int j=0, x; j<M; j++){
			cin >> x;
			present[x].insert(name);
		}
	}

	for(map<int, set<string> >::iterator itr=present.begin(); itr!=present.end(); itr++){
		int sz = itr->second.size();
		set<string>& ss = itr->second;
		for(set<string>::iterator jtr=ss.begin(); jtr!=ss.end(); jtr++){
			points[*jtr] += N - sz + 1;
		}
	}

	int mini = INF;
	string ans = "";
	for(map<string,int>::iterator itr=points.begin(); itr!=points.end(); itr++){
		if(itr->second <= mini){
			if(itr->second < mini|| itr->first < ans){
				ans = itr->first;
				mini = itr->second;
			}
		}
	}

	cout << mini << " " << ans << endl;

	return true;
}

int main(){
	while(doit());

	return 0;
}

Measured memory_bytes: 0
import Foundation
let S = readLine()!

let first = Int(S.substring(with: NSRange(location: 0, length: 2)))
let second = Int(S.substring(with: NSRange(location: 2, length: 2)))

if let f = first, let s = second, 1...12 ~= f || 1...12 ~= s  {
  if f > 12 || f < 1 {
    print("YYMM")
  } else if s > 12 || s < 1 {
    print("MMYY")
  } else {
    print("AMBIGUOUS")
  }
} else {
  print("NA")
}

Measured memory_bytes: 13316
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lld long double
#define w(x) ll x;cin>>x;while(x--)
#define mod 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
    speed;
    ll n;   cin>>n;
    vector<ll> a(n);    for(auto &i:a)  cin>>i;
    vector<ll> dp(n,0);
    dp[n-1]=0;
    for(ll i=n-2;i>=0;i--){
        if(i+2>n-1){
            dp[i]=abs(a[i+1]-a[i])+dp[i+1];
        }
        else{
            dp[i]=min((abs(a[i+1]-a[i])+dp[i+1]),(abs(a[i+2]-a[i])+dp[i+2]));
        }
    }
    cout<<dp[0]<<'\n';
    return 0;
}

Measured memory_bytes: 4648
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13
 
using namespace std;
 
int array[128];
 
int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}
 
int main(){
 
    array['A']=1,array['C']=2,array['G']=3,array['T']=4;
 
    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];
 
    char* check_table = new char[TABLE_SIZE];
 
    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}


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

int main() {
  string S;
  cin >> S;
  string a;
  string x;
  int X;
  int ans = 999;
  for(int i = 0 ; i<=S.size()-3; i++){
  x = a + S.at(i) + S.at(i+1) + S.at(i+2);
  X = stoi(x);
    ans = min(ans,abs(X-753));
}
  cout << ans << endl;
  
  
}


Measured memory_bytes: 384
//ABC164-E
//拡張ダイクストラ

#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<int, P> Pp;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int INF = 1e18;

//銀貨はこれ以上持たなくてよい（最大制約下でも余る）
const int MAX = 2500;

//辺の構造体（次の頂点、運賃、移動時間）
typedef struct Edge{
    int u, c, t;
} Edge;

V(V(Edge)) G(55);
vi C(55), D(55);

//各頂点について、所持している銀貨の枚数ごとの移動時間を記録する
vvi dist(55, vi(MAX, INF));

void dijkstra(int S) {
    S = min(S, MAX);
    dist[0][S] = 0;
    priority_queue<Pp, V(Pp), greater<Pp>> q;
    q.push(Pp(0, P(0, S)));

    while(!q.empty()) {
        Pp p = q.top(); q.pop();
        int v = p.se.fi, d = p.fi, s = p.se.se;
        if(d > dist[v][s]) continue;

        //銀貨の補充は、自分自身への移動と考える
        if(s+C[v] <= MAX) {
            if(d+D[v] < dist[v][s+C[v]]) {
                dist[v][s+C[v]] = d+D[v];
                q.push(Pp(d+D[v], P(v, s+C[v])));
            }
        }

        //通常のダイクストラ
        rep(i, G[v].size()) {
            int nv = G[v][i].u;
            int nd = d + G[v][i].t;
            int ns = s - G[v][i].c;
            if(ns<0) continue;
            if(nd < dist[nv][ns]) {
                dist[nv][ns] = nd;
                q.push(Pp(nd, P(nv, ns)));
            }
        }
    }
}



signed main() {
    int N, M, S;
    cin >> N >> M >> S;
    rep(i, M) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        G[u].pb(Edge{v, a, b});
        G[v].pb(Edge{u, a, b});
    }
    rep(i, N) cin >> C[i] >> D[i];

    dijkstra(S);

    FOR(i, 1, N) {
        int res = INF;
        rep(j, MAX) {
            res = min(res, dist[i][j]);
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 7408
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}
/*
-- bit --
REP(i, (1 << n)) {
	REP(j, n) {
		cout << (1 & (i >> j));
	}
	cout << endl;
}
*/


int main() {
	int n, c;
	cin >> n >> c;
	unordered_map<ll, map<ll, ll>> mp;
	REP(i, n) {
		ll a, b, c;
		cin >> a >> b >> c;
		mp[c].emplace(a, b);
	}

	for (auto&& x : mp) {
		ll f = 0;
		ll e = 0;
		for (auto itr = x.second.begin(); itr != x.second.end();) {
			if (itr->first == e) {
				itr = x.second.erase(--itr);
				x.second.emplace(f, itr->second);
				e = itr->second;
				itr = x.second.erase(itr);
			} else {
				f = itr->first;
				e = itr->second;
				++itr;
			}
		}
	}

	VL v(1e5 + 1);
	REPC(x, mp) {
		REPC(y, x.second) {
			FOR(i, y.first, y.second + 1) {
				++v[i];
			}
		}
	}
	cout << *std::max_element(ALL(v)) << endl;
}

Measured memory_bytes: 7296
s = input()
def rev(s):
  return ''.join(list(reversed(s)))
N = len(s)
f = s[:int((N-1)/2)]
l = s[int((N+3)/2-1):]
if s == rev(s) and f == rev(f) and l == rev(l):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll x;
  cin >> x;
  cout << x * x * x << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3216
#include <iostream>

using namespace std;

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


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

  int count = 1;
  int d = 0;
  REP(i, N) {
    int l;
    cin >> l;
    d += l;
    if (X >= d)
      ++count;
  }

  cout << count << endl;
  return 0;
}


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

int main(){
  int N;
  int a[200];
  int b =0;
  int i,j;
  int count=0;
  
  cin >> N ;
  
  for(i;i<N;i++){
   cin >> a[i];
  }
  j=0;
  while(b == 0){
   if(a[j]%2 == 1){
     b++;
   }else{
     a[j] = a[j]/2;
   }
    j++;
    if(j==N){
      j=0;
      count++;
    }
  }
  
    cout<<count<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
   using namespace std;
   using pii = pair<int, int>;
   using ll = long long;
   #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
   const ll MOD = 1000000007;
   const ll INFL = (1LL << 60);
   const int INFI = (1 << 30);

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

     vector<int> A(N), B(N);

     rep(i, 0, N) cin >> A.at(i) >> B.at(i);

     sort(A.begin(), A.end());
     sort(B.begin(), B.end());

     if (N % 2) {
        cout << B.at((N - 1) / 2) - A.at((N - 1) / 2) + 1 << endl;
     }

     else {
       cout << B.at(N / 2 - 1) + B.at(N / 2) - A.at(N / 2 - 1) - A.at(N / 2) + 1 << endl;
     }
   }


Measured memory_bytes: 4852
n = int(input())

city_pts = {}
cities = set()

for i in range(n):
    city, pts_raw = input().split()
    pts = int(pts_raw)

    if city in cities:
        city_pts[city].append((pts,i))
    else:
        city_pts[city] = [(pts,i)]

    cities.add(city)

for c in sorted(cities):
    pts = city_pts[c]

    for p in sorted(pts,reverse=True):
        print(p[1]+1)




Measured memory_bytes: 38256
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

def want(n):

    xmax = float("-inf")
    xmin = float("inf")
    ymax = float("-inf")
    ymin = float("inf")

    if L:
        xmax = max(xmax,L_R - n)
        xmin = min(xmin,L_L - n)
        ymax = max(ymax,LR_U)
        ymin = min(ymin,LR_D)

    if R:
        xmax = max(xmax,R_R + n)
        xmin = min(xmin,R_L + n)
        ymax = max(ymax,LR_U)
        ymin = min(ymin,LR_D)

    if D:
        xmax = max(xmax,UD_R)
        xmin = min(xmin,UD_L)
        ymax = max(ymax,D_U - n)
        ymin = min(ymin,D_D - n)

    if U:
        xmax = max(xmax,UD_R)
        xmin = min(xmin,UD_L)
        ymax = max(ymax,U_U + n)
        ymin = min(ymin,U_D + n)

    #print (xmax-xmin,ymax-ymin)
    return abs(xmax - xmin) * abs(ymax - ymin)

def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


N = int(input())

UD_L = float("inf")
UD_R = float("-inf")
L_L = float("inf")
L_R = float("-inf")
R_L = float("inf")
R_R = float("-inf")

LR_D = float("inf")
LR_U = float("-inf")
D_D = float("inf")
D_U = float("-inf")
U_D = float("inf")
U_U = float("-inf")

U = False
D = False
L = False
R = False

for i in range(N):

    x,y,d = input().split()

    x = int(x)
    y = int(y)

    if d == "L" or d == "R":
        LR_D = min(LR_D,y)
        LR_U = max(LR_U,y)

        if d == "L":

            L_L = min(L_L,x)
            L_R = max(L_R,x)
            L = True

        else: #R

            R_L = min(R_L,x)
            R_R = max(R_R,x)
            R = True

    if d == "D" or d == "U":

        UD_L = min(UD_L,x)
        UD_R = max(UD_R,x)

        if d == "D":

            D_D = min(D_D,y)
            D_U = max(D_U,y)
            D = True

        else: #U

            U_D = min(U_D,y)
            U_U = max(U_U,y)
            U = True

t0 = 0
t3 = 2 * 10 ** 8
last = float("inf")
ans = 1000000000000000000000

while abs(last - ans) > 10 ** (-100):

    t1 = Decimal((t0 * 2 + t3 * 1)) / Decimal(3)
    t2 = Decimal((t0 * 1 + t3 * 2)) / Decimal(3)

    #print (t1,t2,want(t1),want(t2))

    last = ans
    
    if want(t1) <= want(t2):
        ans = want(t1)
        t3 = t2

    else:
        ans = want(t2)
        t0 = t1

    #print (last,ans,t1,t2)

if ans <= 10 ** (-9):
    ans = 0
print ('{:.20g}'.format(ans))


Measured memory_bytes: 5076
H,W=[int(a) for a in input().split(" ")]
tab=[input() for i in range(H)]
tab2=[]
for row in tab:
    if any([a!="." for a in row]):
        tab2.append(row)
tab = []
for column in zip(*tab2):
    if any([a!="." for a in column]):
        tab.append(column)
for row in zip(*tab):
    print("".join(row))

Measured memory_bytes: 39024
#include <stdio.h>
  
int main(){
      
    int a, b, c, i, j, k;
    int A[100][100], B[100][100];
    long int C[100][100], hoge = 0;
      
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
      
    for(i = 0; i < a; ++i){
        for(j = 0; j < b; ++j){
              
            scanf("%d",&A[i][j]);
        }
    }
      
    for(i = 0; i < b; ++i){
        for(j = 0; j < c; ++j){
              
            scanf("%d",&B[i][j]);
        }
    }
      
      
    for(i = 0; i < a; ++i){
        for(j = 0; j < c; ++j){
            for(k = 0; k < b; ++k){
                  
                hoge += (A[i][k] * B[k][j]);
            }
            C[i][j] = hoge;
            hoge = 0;
        }
    }
      
    for(i = 0; i < a; ++i){
        for(j = 0; j < c; ++j){
              
            if(j == 0){
                printf("%ld",C[i][j]);
            }
            else{
                printf(" %ld",C[i][j]);
            }
        }
        printf("\n");
    }
      
    return 0;
}


Measured memory_bytes: 2092
L = int(input())

l = L
r = 1
nodes = 1
bits = 0
while l!=1:
    bits += l & 1
    l>>=1
    r<<=1
    nodes+=1
print(str(nodes)+" "+str((nodes-1)*2+bits))
#main part
for i in range(1,nodes):
    r>>=1
    print(str(i)+" "+str(i+1)+" "+str(0))
    print(str(i)+" "+str(i+1)+" "+str(r))

r = 1<<(nodes-1)
d = r
for i in range(1,nodes):
    if (r>>i)&L:
        print(str(1)+" "+str(i+1)+" "+str(d))
        d+= (r>>i)
        


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if((a == b && a != c) || (a != b && b == c) || (a == c && c != b))
    cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int M = max({a,b,c});
    if(M%2==0){
        if((a+b+c)%2==0) cout<<(3*M - (a+b+c))/2<<endl;
        else cout<<(3*(M+1)-(a+b+c))/2<<endl;
    }else{
        if((a+b+c)%2==0) cout<<(3*(M+1)-(a+b+c))/2<<endl;
        else cout<<(3*M - (a+b+c))/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,m,k;
    scanf("%lld%lld%lld",&n,&m,&k);
    rep(i,0,m){
        if(i*n>k && m-2*i<0){
            if( (i*n-k) % (2*i-m) ==0 ){
                if( (i*n-k) / (2*i-m) <= n ){
                    // printf("%lld ",i);
                    YES;
                    return 0;
                }
                // printf("A%lld ",i);
            }
        }else if(i*n<=k && m-2*i>0){
            if( (k-i*n) % (m-2*i) ==0 ){
                if( (k-i*n) / (m-2*i) <= n ){
                    YES;
                    return 0;
                }
                // printf("B%lld ",i);
            }
        }
    }
    rep(i,0,n){
        if(i*m>k && n-2*i<0){
            if( (i*m-k) % (2*i-n) ==0 ){
                if( (i*m-k) / (2*i-n) <= m ){
                    YES;
                    return 0;
                }
                // printf("C%lld ",i);
            }
        }else if(i*m<=k && n-2*i>0){
            if( (k-i*m) % (n-2*i) ==0 ){
                if( (k-i*m) / (n-2*i) <= m ){
                    YES;
                    return 0;
                }
                // printf("D%lld ",i);
            }
        }
    }
    NO;
    return 0;
}


Measured memory_bytes: 128
#include<iostream>

int main(){

	int n;
	while (std::cin >> n, n){

		int sum = 0;
		for (int i = 0, a; i < n / 4; i++){
			std::cin >> a;
			sum += a;
		}
		std::cout << sum << std::endl;
	}

	return 0;
}

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

int main(){
    int A, B, cnt = 0;
    cin >> A >> B;
    for(int i = A; i <= B; i++){
        if(i/10000 == i%10 && i/1000-i/10000*10 == (i%100-i%10)/10)
            cnt++;
    }
    cout << cnt <<  endl;
}


Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int A,B; cin>>A>>B;
  string s = string(B, '0'+A);  
  string t = string(A, '0'+B);

  if (s.compare(t) <= 0) cout << s << endl;
  else cout << t << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> v;
  int cnt = 0, prev = 1;
  allrep (c, s) {
    if (c - '0' == prev) ++cnt;
    else {
      v.push_back(cnt);
      cnt  = 1;
      prev = !prev;
    }
  }
  v.push_back(cnt);
  if (s.back() == '0') v.push_back(0);
  vector<int> sumv(v.size() + 1);
  rep (i, v.size()) sumv[i + 1] = sumv[i] + v[i];
  int maxi = 0, times = min(k, (int)v.size() / 2);
  for (int i = 0; i + times * 2 + 1 <= v.size(); i += 2) {
    maxi = max(maxi, sumv[i + times * 2 + 1] - sumv[i]);
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans = 0, a = 0;
  
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      ans += vec.at(i) * vec.at(j);
    }
  }
      
  for (int i = 0; i < N; i++)
    a += vec.at(i) * vec.at(i);
  
  ans = (ans - a) / 2;
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ld a,b,c;
	cin>>a>>b>>c;
	ld k = a/c;
	if(k<=b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	
	


	
	return 0;
}

Measured memory_bytes: 3732
import scala.io.StdIn

object Main extends App {

  case class Point(index: Int, x: Int, y: Int)

  val Array(n, m) = StdIn.readLine().split(" ").map(_.toInt)

  val students = (0 until n).map { i =>
    val pa = StdIn.readLine().split(" ").map(_.toInt)
    Point(i, pa(0), pa(1))
  }

  val checkpoints = (0 until m).map { i =>
    val pa = StdIn.readLine().split(" ").map(_.toInt)
    Point(i + 1, pa(0), pa(1))
  }

  import scala.math.abs
  def distance(s: Point, e: Point) = abs(e.x - s.x) + abs(e.y - s.y)

  val r = students.map{ si =>
    checkpoints.foldLeft(distance(si, checkpoints(0)),checkpoints(0)){ (acc, ci) =>
      val temp = distance(si, ci)
      if(acc._1 > temp) (temp, ci)
      else acc
    }._2.index
  }
  
  r.foreach(println)

}


Measured memory_bytes: 25420
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n;
  cin>>n;
  vector<string> s(2);
  cin>>s[0]>>s[1];
  vector<char> vec;

  for (int i = 0; i < n; ++i)
   {
     if(s[0][i]==s[1][i]){
      vec.push_back('x');
     }
     else{
      vec.push_back('y');
      i++;
     }
   }
   int64_t ans=(vec[0]=='x'? 3:6);
   
   for (int i = 0; i < vec.size()-1; ++i)
   {
     if(vec[i]=='x'){
       ans*=2;
     }
     else if(vec[i+1]=='y'){
       ans*=3;
     }
     ans%=mod;
   }
   cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 
 
int main() 
{
    FAST;
    ll k,p,co;
    cin>>k;
    p=7%k;
    co=1;
    if(k%2==0 || k%5==0)
    {
        cout<<-1;
        return 0;
    }
    while(p!=0)
    {
        p=((p*10ll)+7)%k;
        co++;
    }
    cout<<co;
    subt;
    return 0;
}

Measured memory_bytes: 3796
import java.util.ArrayList;
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		ArrayList<String> word = new ArrayList<>();
		
		ArrayList<Integer> mostCount = new ArrayList<>();
		ArrayList<String> mostWord = new ArrayList<>();
		
		for(int add_count=0; scanner.hasNext();)
		{
			String next = scanner.next();
			word.add(next);
			
			boolean is_add = false;
			for(int j=0; j<add_count; j++)
			{
				if(next.equals(mostWord.get(j)))
				{
					is_add = true;
					mostCount.set(j, mostCount.get(j)+1);
				}
			}
			if(!is_add)
			{
				add_count++;
				mostCount.add(1);
				mostWord.add(next);
			}
		}
		
		int len_max = 0;
		String str_len = "";
		for(int i=0; i<word.size(); i++)
		{
			String w = word.get(i);
			if(w.length() > len_max)
			{
				len_max = w.length();
				str_len = w;
			}
		}
		
		int word_max = 0;
		String str_most = "";
		for(int i=0; i<mostCount.size(); i++)
		{
			int cnt = mostCount.get(i);
			if(word_max < cnt)
			{
				word_max = cnt;
				str_most = mostWord.get(i);
			}
		}
		System.out.println(str_most +" "+ str_len);
	}
}

Measured memory_bytes: 25988
#include<stdio.h>
int main(void)
{
    long long int n,i,j,ans=0;
    scanf("%lld",&n);
    for(i=n;i>0;i--){
        j=1;
        while((j*j)<=i){
            if((j*j)==i)
                ans=i;
            j++;
        }
        if(ans!=0)
            break;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstdio>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

struct point { double x, y; };
struct line { point p, q; };
struct rect { point p[4]; line l[4]; };

int N;
double LX[50], LY[50], RX[50], RY[50], H[50];
point S, E;
line c;
rect o[50];
double d[50];

bool intersect(line l1, line l2) {
  double ax = l1.p.x, ay = l1.p.y;
  double bx = l1.q.x, by = l1.q.y;
  double cx = l2.p.x, cy = l2.p.y;
  double dx = l2.q.x, dy = l2.q.y;
  double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
  double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
  double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
  double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
  return tc * td < 0 && ta * tb < 0;
}

double distance(line l, point p) {
  double x0 = p.x, y0 = p.y;
  double x1 = l.p.x, y1 = l.p.y;
  double x2 = l.q.x, y2 = l.q.y;
  double a = x2 - x1;
  double b = y2 - y1;
  double a2 = a * a;
  double b2 = b * b;
  double r2 = a2 + b2;
  double tt = -(a*(x1 - x0) + b*(y1 - y0));
  if(tt < 0) return sqrt((x1 - x0)*(x1-x0) + (y1 - y0)*(y1-y0));
  if(tt > r2) return sqrt((x2 - x0)*(x2 - x0) + (y2 - y0)*(y2 - y0));
  double f1 = a*(y1 - y0) - b*(x1 - x0);
  return sqrt((f1*f1)/r2);
}

bool check(double r) {
  REP(i, 0, N) if(d[i] < sqrt(pow(r, 2) - pow(r - min(r, (double) H[i]), 2))) return false;
  return true;
}

double solve() {
  REP(i, 0, N) REP(j, 0, 4) {
    if(intersect(c, o[i].l[j])) return 0;
    if(LX[i] <= S.x && S.x <= RX[i] && LY[i] <= S.y && S.y <= RY[i]) return 0;
    if(LX[i] <= E.x && E.x <= RX[i] && LY[i] <= E.y && E.y <= RY[i]) return 0;
  }

  REP(i, 0, N) {
    d[i] = 1e10;
    REP(j, 0, 4) {
      d[i] = min(d[i], distance(c, o[i].p[j]));
      d[i] = min(d[i], distance(o[i].l[j], S));
      d[i] = min(d[i], distance(o[i].l[j], E));
    }
  }

  double low = 0, high = 1005;
  REP(i, 0, 100) {
    double mid = (low + high) * 0.5;
    if(check(mid)) low = mid;
    else high = mid;
  }
  return low;
}

int main(void) {
  while(cin >> N, N) {
    cin >> S.x >> S.y >> E.x >> E.y;
    c = (line) { S, E };

    REP(i, 0, N) {
      cin >> LX[i] >> LY[i] >> RX[i] >> RY[i] >> H[i];
      o[i].p[0] = (point) { LX[i], LY[i] };
      o[i].p[1] = (point) { LX[i], RY[i] };
      o[i].p[2] = (point) { RX[i], RY[i] };
      o[i].p[3] = (point) { RX[i], LY[i] };
      o[i].l[0] = (line) { o[i].p[0], o[i].p[1] };
      o[i].l[1] = (line) { o[i].p[1], o[i].p[2] };
      o[i].l[2] = (line) { o[i].p[2], o[i].p[3] };
      o[i].l[3] = (line) { o[i].p[3], o[i].p[0] };
    }

    printf("%.8lf\n", solve());
  }

  return 0;
}

Measured memory_bytes: 3212
N, L = map(int, input().split())
eat = 300
x = 0
for i in range(1, N + 1):
    aji = abs(L + i - 1)
    if eat > aji:
        eat = aji
        x = L + i - 1
print(sum(range(1, N + 1)) + N * (L - 1) - x)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    char dif= 'A' - 'a';
    printf("%c%c%c\n", a[0] + dif, b[0] + dif, c[0] + dif);
    
    
    return 0;
}



Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {

        var N = Console.ReadLine();
        Console.WriteLine(N.Where(X => X == '2').Count());
        Console.ReadLine();
    }


    
    
    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
}


Measured memory_bytes: 11348
// 写経 https://atcoder.jp/contests/abc117/submissions/4157302
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(long long i = 0;i < n;++i)

long long on[64] = {};
long long off[64] = {};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n, k;
	cin >> n >> k;
	REP(i, n){
		long long a;
		cin >> a;
		for(int i = 0; i < 64; ++i){
			if(a%2 == 0) off[i]++;
			else on[i]++;
			a /= 2;
		}
	}
	long long ans = 0;
	for(long long i = 60; i >= 0; i--){
		long long bo = 1;
		for(int j = 0; j < i; j++){
			bo *= 2;
		}
		if(k >= bo){
			if(off[i] > on[i]){
				k -= bo;
				ans += bo * off[i];
				continue;
			}
		}
		ans += bo * on[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	string s;
	cin >> s;

	for (int i = (s.size() - 1) / 2; i >= 0 ; i--) {
		DMP(i);
		DMP(s.substr(0, i), s.substr(i, i));
		if (s.substr(0, i) == s.substr(i, i)) {
			cout << 2 * i << "\n";
			break;

		}

	}

	return 0;
}

Measured memory_bytes: 256
def bsearch_min(a, c)
  l, r = 0, a.size - 1
  while l <= r
    m = l + (r - l) / 2
    if a[m] < c
      l = m + 1
    else
      r = m - 1
    end
  end
  l
end

def bsearch_min2(a, c)
  l, r = 0, a.size - 1
  while l <= r
    m = l + (r - l) / 2
    if a[m] <= c
      l = m + 1
    else
      r = m - 1
    end
  end
  l
end

n = gets.to_i
a = gets.split.map(&:to_i).sort
b = gets.split.map(&:to_i).sort
c = gets.split.map(&:to_i).sort


ak = Array.new(n, 0)
ck = Array.new(n, 0)

n.times{|i|
  ak[i] = bsearch_min(a, b[i])
  ck[i] = n - bsearch_min2(c, b[i])
}

a=0
n.times{|i|
  a += ak[i]*ck[i]
}

p a

Measured memory_bytes: 25456
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);

    vector<int> A(N);
    set< pair<ll, ll> > S;
    for(int i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }
    sort(A.begin(), A.end());
    for(int i=0; i<N; i++) {
        S.emplace(A[i], i);
    }

    vector<ll> twos(1, 1);
    while(twos.back() <= (ll)2e9) {
        ll value = twos.back() << 1;
        twos.emplace_back(value);
    }
    reverse(twos.begin(), twos.end());

    int ans = 0;
    for(int i=N-1; i>=0; i--) {
        if(!S.count(make_pair(A[i], i))) continue;
        S.erase(make_pair(A[i], i));
        for(auto v : twos) {
            if(A[i] >= v) continue;
            ll req = v - A[i];
            auto itr = S.lower_bound(make_pair(req, -1));
            if(itr != S.end() and itr->first == req) {
                ans++;
                S.erase(itr);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16484
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll arr[MAX],l[MAX],r[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    for(int i=1;i<=n;i++)
        l[i]=l[i-1]+arr[i];
    for(int i=n;i>=1;i--)
        r[i]=r[i+1]+arr[i];
    ll ans=1e18;
    for(int i=1;i<n;i++)
        ans=min(ans,llabs(l[i]-r[i+1]));
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 8280
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long int ll;


int main()
{
	int n;
	cin >> n;
	int ans = 1;
	for (int i = 1; i*i <= n; i++) {
		ans = i * i;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int ans=1;
  rep(i,10){
    if(ans*2<=n){
      ans*=2;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		a[i] = i + 1;
	}
	
	vector<int> p(n);
	vector<int> q(n);
	for(int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> q[i];
	}

	vector<vector<int>> v(50000,vector<int>(n));
	int j = 0;
	do{
        for(int i=0; i<n; i++){
            v[j][i]=a[i];
        }
		j++;
    }while(next_permutation(ALL(a)));
	int P,Q;
	for(int i = 0; i < 40320; i++) {
		if (p == v[i]){
			P = i;
		}
		if(q == v[i]){
			Q = i;
		}
	}
	cout << abs(P - Q)  << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,x,y;cin >> n >> m >> x >> y;
	for(int i = 0;i < n;i++)
	{
		int xd;cin >> xd;x = max(x,xd);
	}
	for(int i = 0;i < m;i++)
	{
		int yd;cin >> yd;y = min(y,yd);
	}
	string k = "War";
	if(x < y)k = "No War";
	cout << k << endl;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    string ans="YES";
    sort(a.begin(), a.end());
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            ans="NO";
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<sstream>
using namespace std;

int main()
{


	int a, b;
	while (cin >> a >> b) {
		stringstream ss;
		string sum;
		ss << a + b;
		sum = ss.str();

		cout << sum.size() << endl;
	}

	return 0;
}

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

int main(){
  int n; cin>>n;
  vector<int> base(n-1),num(n);
  for(int i=0;i<n-1;i++){
    cin>>base[i];
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      num[i]=base[n-2];
    }else if(i==0){
      num[i]=base[i];
    }else{
      num[i]=min(base[i],base[i-1]);
    }
  }long long ans=0;
  for(int i=0;i<n;i++){
    ans+=num[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int quick_pow(int n)
{
    int ans=1;
    int base=2;
    while(n){
        if(n&1)
            ans*=base;
        n>>=1;
        base*=base;
    }
    return ans;
}
int main()
{
    queue<int>q;
    int n,k;
    double ans=0;
    int cnt=0;
    int mx=0;
    int op;
    cin>>n>>k;
    for(int i=1;i<=n;++i)
    {
        cnt=0;
        for(int tp=i;tp<k;tp*=2){
            ++cnt;
        }
        op=quick_pow(cnt);
        mx=max(mx,op);
        q.push(op);
    }
    int ac=0;
    while(!q.empty())
    {
        ac+=mx/q.front();
        q.pop();
    }
    ans=ac*1.0/mx/n;
    //cout<<ac<<" "<<mx<<endl;
    cout<<setiosflags(ios::fixed)<<setprecision(12);
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int count = 0;
	for(int i = min(a,b); i >= 1; i--) {
		if(a%i==0&&b%i==0) {
			count++;
			//cout << i << endl;
			if(c==count) {
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    n %= 10;
    if(n == 3) cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}


Measured memory_bytes: 3656
N = int(input())
A = list(map(int, input().split()))

AA = [0]
AA.extend(A)
AA.append(0)

Adif1 = []

for i in range(1, N + 2):
	x = abs(AA[i] - AA[i - 1])
	Adif1.append(x)

s = sum(Adif1)

Adif2 = []

for i in range(2, N + 2):
	x = abs(AA[i] - AA[i - 2])
	Adif2.append(x)

for i in range(N):
	print(s + Adif2[i] - Adif1[i] - Adif1[i + 1])

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

int main()
{
  int x[5];
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
  for (int i = 0; i < 5; i++)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,m;
	cin>>n>>m;
	int map[30]={};
	fori(n){
		int k;
		cin>>k;
		forj(k){
			int hoge;
			cin>>hoge;
			++map[hoge-1];
		}
	}

	int c=0;
	fori(m){
		if(map[i]==n){
			++c;
		}
	}
	cout<<c;
}

Measured memory_bytes: 256
/*
 * 17-04-22_ARC072_C.cpp
 *
 *  Created on: 2017/04/22
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int N;
ll a[100010];
ull ans;

ull solve(ll prev,ll sum,ull p){
	ull res = p;
	for(int i=1;i<N;i++){
		//cout<<sum<<endl;
		sum += a[i];
		if(sum == 0){
			res ++;
			sum = -prev/abs(prev);
		}
		else if(sum * prev > 0){
			res += abs(sum)+1;
			sum = -prev/abs(prev);
		}
		prev = sum;
	}
	return res;
}

int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	ull r1,r2;
	if(a[0] == 0){
		r1 = solve(1,1,1);
		r2 = solve(-1,-1,1);
	}
	else{
		r1 = solve(a[0],a[0],0);
		r2 = solve(-a[0]/abs(a[0]),-a[0]/abs(a[0]),abs(a[0])+1);
	}
	ans = min(r1,r2);
	//cout << r1 << " "<<r2<<endl;
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 1024
A, B, X = gets.split.map(&:to_f)

s = X/A
if s >= A*B / 2
  s  = A*B - s
  t = Math.atan2(2*s / A, A)
else
  t = Math.atan2(B, 2*s / B)
end
puts t / Math::PI * 180

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    int oddNum = 0;
    vector<int> a(m);
    for(int i=0; i<m; ++i){
        cin >> a[i];
        if(a[i] % 2 != 0){
            swap(a[i], a[oddNum]);
            ++ oddNum;
        }
    }
    if(oddNum > 2){
        cout << "Impossible" << endl;
        return 0;
    }
    else if(oddNum == 2){
        swap(a[1], a[m-1]);
    }

    vector<int> b = a;
    if(b.size() == 1){
        if(n != 1){
            -- b[0];
            b.push_back(1);
        }
    }
    else{
        -- b[0];
        ++ b[m-1];
        if(b[0] == 0)
            b.erase(b.begin());
    }

    cout << a[0];
    for(unsigned i=1; i<a.size(); ++i)
        cout << ' ' << a[i];
    cout << endl << b.size() << endl << b[0];
    for(unsigned i=1; i<b.size(); ++i)
        cout << ' ' << b[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split(' '))
H=list(map(int,input().split(' ')))
ans = 1
ans_t=abs(A-(T-H[1]*0.006))
for i in range(N):
    if abs(A-(T-H[i]*0.006)) < ans_t:
        ans = i+1
        ans_t=abs(A-(T-H[i]*0.006))
print(ans)

Measured memory_bytes: 3064