akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  string s,t;
  cin>>n>>s>>t;
  {
    string x(s),y(t);
    x.erase(unique(x.begin(),x.end()),x.end());
    y.erase(unique(y.begin(),y.end()),y.end());
    if(x.size()>y.size()) swap(s,t);
  }
  const Int MAX = 5050;
  Int ans=1e9;

  using D = deque<Int>;
  auto gen=
    [&](string x){
      D res;
      char lst='$';
      for(char c:x){
        if(res.empty()||lst!=c) res.emplace_back(0);
        res.back()++;
        lst=c;
      }
      return res;
    };
  
  auto solve=
    [&]()->void{
      D v2=gen(t);
      
      for(Int i=0;i<MAX;i++){        
        D v1=gen(s);        
        Int res=0;
        
        Int posL=0,posR1=v1.size()-1,posR2=posR1;
        auto incL=
          [&](){
            chmin(posL,(Int)v1.size()-1);
            while(posL<(Int)v1.size()&&v1[posL]!=2) posL++;
            if(posL<(Int)v1.size()){
              v1[posL]=1;
              v1.emplace_front(1);
              res+=posL+1;
              posR1++;
              posR2++;
            }else{
              res+=posL;
            }   
          };
        
        auto incR=
          [&](){
            chmin(posR1,(Int)v1.size()-1);
            while(posR1>=0&&v1[posR1]!=2) posR1--;
            assert(posR1>=0);
            
            v1[posR1]=1;
            res+=v1.size()-posR1;
            v1.emplace_back(1);
          };
        auto decR=
          [&](){
            chmin(posR2,(Int)v1.size()-1);
            while(posR2>=0&&v1[posR2]!=1) posR2--;
            Int posR3=posR2-1;
            while(posR3>=0&&v1[posR3]!=1) posR3--;                        
            assert(posR3>=0);
            res+=v1.size()-(posR2+1);
            res+=v1.size()-(posR3+2);
            res+=1;
            v1[posR2]=v1[posR3]=2;
            v1.pop_back();            
          };
        
        if(s[0]!=t[0]) incL();
        for(Int j=0;j<i;j++){
          incL();incL();
        }
        //cout<<i<<":"<<v1.size()<<" "<<v2.size()<<endl;
        
        while(v1.size()<v2.size()) incR();
        while(v1.size()>v2.size()) decR();
        //cout<<i<<":"<<v1.size()<<" "<<v2.size()<<endl;

        Int a=0,b=0;
        for(Int i=0;i<(Int)v1.size();i++){
          a+=v1[i];
          b+=v2[i];
          res+=abs(a-b);
        }
        //cout<<i<<":"<<res<<endl;
        chmin(ans,res);
      }   
    };

  for(Int uku=0;uku<2;uku++){
    solve();
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
  }  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
typedef long long T;
 
struct point { 
    T x,y;
    int i; 
    point operator - (const point &rhs) {
        return {x-rhs.x, y-rhs.y};
    }
    T dot(const point &rhs) {
        return x*rhs.x + y*rhs.y;
    }
    T cross(const point &rhs) {
        return x*rhs.y - y*rhs.x;
    }
    T len2() {
        return x*x + y*y;
    }
};
 
int compare(T x, T y) {
    if(y-x > 0) return -1;
    if(x-y > 0) return 1;   
    return 0;
}
 
T cross(point p, point q, point r) { return (r-q).cross(p-q); }
 
int turn(point p, point q, point r) { return compare(cross(p,q,r), 0); }
 
int cw(point p, point q, point r) { return turn(p,q,r) < 0; }
 
double angle(point a, point o, point b) // angle AOB (radians)
{
   point u = {a.x - o.x, a.y - o.y}; // u: vector oa
   point v = {b.x - o.x, b.y - o.y}; // v: vector ob
   return acos(u.dot(v) / sqrt(1.0 * u.len2() * v.len2())); // dot product
}

bool cmp(const point &p, const point &q)
{
    return p.x < q.x || (p.x == q.x && p.y < q.y);
}
 
vector<point> convex_hull(vector<point> &p)
{
    int n = (int)p.size(), k = 0;
    vector<point> h(2 * n);
    sort(p.begin(), p.end(), cmp);
    for(int i = 0; i < n; i++) 
    {
        while(k >= 2 && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    for(int i = n - 2, t = k + 1; i >= 0; i--) 
    {
        while(k >= t && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    h.resize(k); h.pop_back(); 
    return h;
}
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(10);
    int n,m;
    vector<point> p,h;
    double ans[105];
    while(cin >> n)
    {
        p = vector<point>(n);
        for(int i = 0; i < n; i++)
        {
            cin >> p[i].x >> p[i].y;
            p[i].i = i;
        }
        h = convex_hull(p);
        for(int i = 0; i < n; i++)
            ans[i] = 0;
        m = h.size();
        for(int i = 0; i < m; i++)
            ans[h[i].i] = (M_PI - angle(h[(i-1+m)%m], h[i], h[(i+1)%m])) / (2*M_PI);
        for(int i = 0; i < n; i++)
            cout << ans[i] << '\n';
    }
    return 0;
} 

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i;
	cin >> n;
	vi l(2 * n);
	for (i = 0; i < 2 * n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (i = 0; i < n; i++) {
		ans += l[2*i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 10000000000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int n, c, k, a[100010], ta, mu, ans;

signed main() {
	cin >> n >> c >> k;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	rep(i, n) {
		if (ta == c || mu < a[i]) {
			ans++;
			ta = 1;
			mu = a[i] + k;
		}
		else ta++;
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;

int main() {
	int N, T;
	cin >> N >> T;
	int ans = INT_MAX;
	for (int i = 0; i < N; ++i) {
		int c, t;
		cin >> c >> t;
		if (t <= T) ans = min(ans, c);
	}
	if (ans == INT_MAX) {
		cout << "TLE" << endl;
		return 0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder_A_RedOrNot
{
    class A_RedOrNot
    {
        static void Main(string[] args)
        {
            int a = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();

            if (a < 3200)
            {
                Console.WriteLine("red");
            }
            else
            {
                Console.WriteLine(s);
            }
        }
    }
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> as(n+1);
    for(int i=0; i<n+1; i++) cin >> as.at(i);
    vector<int> bs(n);
    for(int i=0; i<n; i++) cin >> bs.at(i);

    ll ans = 0;
    for(int i=n-1; i>=0; i--)
    {
        int ti1 = (as.at(i+1) <= bs.at(i)) ? as.at(i+1) : bs.at(i);
        ans += ti1;
        bs.at(i) -= ti1;
        int ti0 = (as.at(i) <= bs.at(i)) ? as.at(i) : bs.at(i);
        ans += ti0;
        as.at(i) -= ti0;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
   long long int a,b,c,d;
   cin>>a>>b>>c>>d;
   int flag = 1;
   while(a>0 || c>0)
   {
       if(flag)
       {
           c -= b;
       }
       else
       {
           a -= d;
       }
       flag = (flag+1)%2;
   }
   if(flag==1)
   cout<<"Yes";
   else if(flag==0)
   cout<<"No";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  long long A, B, C;
  cin >> A >> B >> C;

  long long ans;
  if (A * B * C % 2 == 0) ans = 0;
  else ans = min({A * B, B * C, C * A});
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;

int main(){
	int sum = 0;
	for(int i = 0 ; i < 10 ; i++){
		int t; cin >> t;
		sum += t;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    int a, b, k;
    std::cin >> a >> b >> k;

    auto lambda = [&](int n) {
        if (n % 2 == 0) {
            if (a % 2) {
                a--;
            }

            b += a / 2;
            a /= 2;
        } else {
            if (b % 2) {
                b--;
            }

            a += b / 2;
            b /= 2;
        }
    };

    for (int i = 0; i < k; i++) {
        lambda(i);
    }

    std::cout << a << " " << b << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;
typedef long long ll;
ll num[100010];
int main() {
	ll n, a, ans = 0;
	cin >> n;
	for (ll i = 0;i < n;i++) {
		cin >> a;
		num[a]++;
	}
	for (ll i = 0;i <= 100000;i++) {
		if (i == 0)ans = max(ans, num[0] + num[1]);
		else {
			if (i == 100000)ans = max(ans, num[99999] + num[100000]);
			else ans = max(ans, num[i - 1] + num[i] + num[i + 1]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  std::sort(L.begin(), L.end());

  int sum {};
  rep(i, N-1) sum += L[i];
  if (sum <= L[N-1]) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
}


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

using namespace std;

int main() {
    string q;
    cin >> q;
    string trg = "keyence";
    int n = trg.size();
    
    int deleteCount = 1;
    for (int i = 0; i <= n; ++i) {
        //cout << i << endl;
        bool toOuterLoop = false;
        for (int j = 0; j < i; ++j) {
            if (q[j] != trg[j]) {
                toOuterLoop = true;
                break;
            }
        }
        if (toOuterLoop) {
            //cout << "outer:" << i << endl;
            continue;
        }
        int start = q.size() - n + i;
        //cout << "i:" << i << endl;
        //cout << "start:" << start << endl;
        for (int j = start; j < q.size(); ++j) {
            if (q[j] != trg[i+j-start]) {
                toOuterLoop = true;
                break;
            }
        }
        if (toOuterLoop) {
            continue;
        }
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from bisect import bisect
N=int(input())
X=[int(i) for i in input().split()]
L=int(input())
Q=int(input())
#T=[[int(i) for i in input().split()] for i in range(Q)]
T=[]
for i in range(Q):
    a,b=map(int,input().split())
    if a>b:
        a,b=b,a
    T.append((a-1,b-1))
F=[0]*N
for i in range(N):
    F[i]= bisect(X, X[i] + L) -1
#print(F)
dp=[ [N-1] * (N) for i in range(18)]

for i in range(N):
    #dp[0][i]=i
    dp[0][i]=F[i]
for c in range(1,18):
    for i in range(N):
        dp[c][i] = dp[c-1][ dp[c-1][i] ]
#print(dp)

def f(a,b):
    num=0
    t = a
    while True:
        for i in range(18):
            if dp[i][t]>=b:
                s=i
                break
        if s==0:
            num+=1
            break
        num += pow(2, s - 1)
        t = dp[s-1][t]
    print(num)
for a,b in T:
    f(a,b)



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

#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define tc              int t;cin>>t
#define w               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool vis[100009];
long long n;
int cnt=0,l=0,r=0;

int main() {
#ifndef ONLINE_JUDGE
	//freopen("test.txt", "rt", stdin);
#endif
int a,b,c;
cin>>a>>b>>c;
swap(a,b);
swap(a,c);
cout<<a<<" "<<b<<" "<<c;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 205 ;
int n ;
char s[maxn] , t[maxn] ;
int main()
{
	scanf("%d" , &n) ;
	scanf("%s%s" , s , t) ;
	for(int i = 0 ; i < n ; i ++)
	  printf("%c%c" , s[i] , t[i]) ;
	printf("\n") ;
    return 0 ;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        es: [(usize1, usize1); m]
    }
    let mut g = vec![vec![]; n];
    for &(a, b) in &es {
        g[a].push(b);
        g[b].push(a);
    }
    println!("{}", bridges(&g).len());
}

fn bridges(g: &Vec<Vec<usize>>) -> Vec<(usize, usize)> {
    let n = g.len();
    let mut pre = vec![n; n];
    let mut low = vec![n; n];
    let mut bs = vec![];
    for i in 0..n {
        if pre[i] != n {
            continue;
        }
        pre[i] = 0;
        low[i] = 0;
        bridges_dfs(i, i, 1, g, &mut pre, &mut low, &mut bs);
    }
    bs
}

fn bridges_dfs(r: usize, p: usize, mut next: usize, g: &Vec<Vec<usize>>, pre: &mut Vec<usize>, low: &mut Vec<usize>, bs: &mut Vec<(usize, usize)>) {
    let n = g.len();
    for &c in &g[r] {
        if c == p {
            continue;
        }
        if pre[c] == n {
            pre[c] = next;
            low[c] = pre[c];
            next += 1;
            bridges_dfs(c ,r, next, g, pre, low, bs);
            if low[r] >= low[c] {
                low[r] = low[c];
            }
        } else if pre[c] < pre[r] && low[r] > pre[c] {
            low[r] = pre[c];
        }
        if low[c] > pre[r] {
            bs.push((r, c));
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

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

    if (500*K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import collections

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
cnt=collections.Counter(arr)
for i in range(n):
  if arr[i] in s:
    continue
  if cnt[arr[i]]>=2:
    s.add(arr[i])
  for j in range(2,10**6//arr[i]+1):
    s.add(arr[i]*j)
ans=0
for i in range(n):
  if arr[i] in s:
    continue
  if cnt[arr[i]]>=2:
    continue
  ans+=1
print(ans)


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

map<string, vector<string> > G;
map<string, bool> is_group;
map<string, bool> used;
int N;
int cnt;

void dfs(string s) {
  if ( used[s] ) return;
  used[s] = true;
  if ( is_group[s] ) {
    for ( string t : G[s] ) {
      dfs(t);      
    }
  } else {
    cnt++;
  }
}

int main() {
  while ( cin >> N, N ) {
    string g1 = "";    
    G.clear();
    is_group.clear();
    used.clear();
    cnt = 0;
    for ( int n = 0; n < N; n++ ) {
      string group;
      string s;    
      string t = "";
      cin >> s;      
      for ( int i = 0; i < (int)s.size(); i++ ) {
	if ( s[i] == ':' ) {
	  group = t;
	  is_group[t] = true;	  
	  if ( g1 == "" ) g1 = group;	  
	  t = "";
	} else if ( s[i] == ',' || s[i] == '.' ) {
	  G[group].emplace_back(t);	  
	  t ="";
	} else {
	  t += s[i];	  
	}
      }
    }

    dfs(g1);
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3396
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V

main = abc162c

abc162c = do
    [k] <- getIntList
    print $ sum (gcd3List $ fromIntegral k)

getGCD (a, b)
    | a < b = getGCD (b, a)
    | mod a b == 0 = b
    | otherwise = getGCD (b, mod a b)

getGCD3 (a, b, c) = getGCD (getGCD (a,b), getGCD (a,c)) 

gcd3List k = [getGCD3 (a,b,c) | a <- [1..k], b <- [1..k], c <- [1..k]]

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 4876
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    vector<ll> c1;
    vector<ll> c2;
    for (int i = 0; i < n / 2; ++i)
    {
        c1.push_back(a[i]);
        c2.push_back(a[n - 1 - i]);
    }
    
    ll r1 = 0;
    ll r2 = 0;
    for (int i = 0; i < c1.size() - 1; ++i)
    {
        r1 += c1[i];
    }
    for (int i = 0; i < c2.size() - 1; ++i)
    {
        r2 += c2[i];
    }
    r1 *= 2ll;
    r2 *= 2ll;
    ll ret = r2 - r1 + c2[c2.size() - 1] - c1[c1.size() - 1];
    if (n % 2)
    {
        cout << max(ret + c2[c2.size() - 1] - a[n / 2], ret + a[n / 2] - c1[c1.size() - 1]) << endl;
    }
    else
    {
        cout << ret << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long a[n];
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<>());
  long sh = 0;
  long lo = 0;
  for(i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      if(lo==0)lo=a[i];
      else{
        sh = a[i];
        break;
      }
      i++;
    }
  }
  cout << lo*sh;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

const ll mod = 1e9+7;
ll power(ll x, ll y, ll m=mod) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2ll, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

ll modInverse(ll a, ll m = mod) 
{ 
    return power(a, m-2ll, m); 
} 

void solve() {
    ll n, k, i, j, p, q, ans = 0;
    n = 3;
    cin>>k;
    ll a[k+1];
    Fo(i,1,k+1) {
        a[i] = power(k/i, n);
    }
    for(i=k;i>0;i--) {
        j = 2*i;
        while(j<=k) {
            a[i] = ( a[i] - a[j] + mod ) % mod;
            j += i;
        }
        ans = ( ans + a[i] * i ) % mod;
        // debug2(i,a[i]);
    }
    ans = (ans+mod)%mod;
    cout<<ans;
}

/*void solve() {
    ll n, i, j, k, ans = 0, r[4001], g[4001], b[4001];
    string s;
    cin>>n>>s;
    fo(i,n)r[i]=g[i]=b[i]=0;
    ans = n * ( n-1ll ) * ( n-2ll ) / 6ll;
    fo(i,n) {
        if(s[i]=='R') {
            r[i] = 1;
        }
        if(s[i]=='G') {
            g[i] = 1;
        }
        if(s[i]=='B') {
            b[i] = 1;
        }
        if(i>0) {
            r[i] += r[i-1];
            g[i] += g[i-1];
            b[i] += b[i-1];
        }
    }
    fo(i,n) {
        Fo(k,i+2,n) {
            if(s[i]==s[k]) {
                if(s[i]=='R')ans -= r[k-1] - r[i];
                if(s[i]=='G')ans -= g[k-1] - g[i];
                if(s[i]=='B')ans -= b[k-1] - b[i];
            } else {
                if(s[i]=='R')ans -= r[k-1] - r[i];
                if(s[i]=='G')ans -= g[k-1] - g[i];
                if(s[i]=='B')ans -= b[k-1] - b[i];
                if(s[k]=='R')ans -= r[k-1] - r[i];
                if(s[k]=='G')ans -= g[k-1] - g[i];
                if(s[k]=='B')ans -= b[k-1] - b[i];
            }
            if((k+i)%2==0) {
                j = (k+i)/2;
                if(s[i]!=s[j] and s[k]!=s[j])ans--;
            }
        }
    }
    cout<<ans<<endl;
}*/

int main()
{
    fastIO;ll t=1;
    // cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3640
#include<iostream>
#include<queue>
#include<algorithm>
#include<string.h>
using namespace std;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1}; 
char ch[1111][1111];
int used[1111][1111];
int step[1111][1111];
queue<pair<int,int> > q;
int main()
{
	memset(used,0,sizeof(used));
	memset(step,0,sizeof(step));
	int n,m,k,ans=1000000,sx,sy;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>ch[i][j];
			if(ch[i][j]=='S')
			{
				sx=i;
				sy=j;
			}
		}
	}
	q.push(make_pair(sx,sy));
	used[sx][sy]=1;
	while(!q.empty())
	{
		pair<int,int> hh=q.front();
		q.pop();
		int x=hh.first;
		int y=hh.second;
		for(int i=0;i<4;i++)
		{
			int xx=x+dx[i];
			int yy=y+dy[i];
			if(!xx||!yy||xx>n||yy>m||ch[xx][yy]=='#') continue;
			if(!used[xx][yy])
			{
				used[xx][yy]=1;
				step[xx][yy]=step[x][y]+1;
				q.push(make_pair(xx,yy));
			}
		}
	}
	/*for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<step[i][j]<<" ";
		}
		cout<<endl;
	}*/
	//cout<<endl;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if((step[i][j]&&step[i][j]<=k)||ch[i][j]=='S')
			{
				int dis=min(abs(i-1),min(abs(n-i),min(abs(j-1),abs(m-j))));
				int step=(dis+k-1)/k;
				ans=min(ans,step+1);
			}
		}
	}
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 10752
# -*- coding: utf-8 -*-

# Input
s = [input() for i in range(1)]

N = int(s[0].split()[0])
K = int(s[0].split()[1])
Q = int(s[0].split()[2])

# 正解した者の番号の列
A = [int(input()) for i in range(2, Q+2)]

# スタート時のポイント初期値
B = [K-Q for i in range(N)]

# 各参加者の正解数をカウントする
for i in range(Q):
    B[A[i]-1] = B[A[i]-1] + 1

# Output
for i in range(N):
    if B[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,k;
    cin>>n>>k;
    int a,b,c;
    cin>>a>>b>>c;
    string s;
    cin>>s;
    map<char,int>mp;
    mp['r',a];
    mp['s',b];
    mp['p',c];
    int sum=0;
    vector<char>vec;
    //vec.push_back('k');
    for(int i=0; i<s.size(); i++)
    {
        if(i<k)
        {
            if(s[i]=='s')
                sum+=a,vec.push_back('r');
            else if(s[i]=='p')
                sum+=b,vec.push_back('s');
            else if(s[i]=='r')
                sum+=c,vec.push_back('p');
        }
        else
        {
            if(s[i]=='s')
            {
                if(vec[i-k]!='r')
                    sum+=a,vec.push_back('r');
                else
                    vec.push_back('A');
            }
            else if(s[i]=='p')
            {
                if(vec[i-k]!='s')
                    sum+=b,vec.push_back('s');
                else
                    vec.push_back('A');
            }
            else if(s[i]=='r')
            {
                if(vec[i-k]!='p')
                    sum+=c,vec.push_back('p');
                else
                    vec.push_back('A');
            }
        }
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 640
N=int(input())
a=[0]*10**4
for j in range(1,101):
    for k in range(1,101):
        for h in range(1,101):
            tmp=h**2+j**2+k**2+h*j+j*k+k*h
            if tmp<=10000:
                a[tmp-1]+=1
for i in range(N):
    print(a[i])


Measured memory_bytes: 9432
from sys import stdout
import heapq
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def dumpheap(h):
    a = []
    print("- -")
    while len(h)>0:
        z = heapq.heappop(h)
        print(z)
        a.append(z)
    for z in a:
        heapq.heappush(h,z)

n,m = inm()
a = []
for i in range(m):
    l,r,c = inm()
    a.append((l,r,c))
a.sort()
if a[0][0]>1:
    print(-1)
    exit()

ddprint(a)

h = []
top = 0
for i in range(m):
    l,r,c = a[i]
    if l==1:
        heapq.heappush(h,(c,0,l,r,c))
    else:
        top = i
        break

if DBG:
    dumpheap(h)

curld,curd,curl,curr,curc = heapq.heappop(h)
for i in range(top,m):
    l,r,c = a[i]
    while curr<l:
        if len(h)==0:
            print(-1)
            exit()
        curld,curd,curl,curr,curc = heapq.heappop(h)
    heapq.heappush(h,(curld,curd,curl,curr,curc))
    #ddprint("push {} {} {} {} {}".format(curld+c,curld,l,r,c))
    heapq.heappush(h,(curld+c,curld,l,r,c))

r=0
while r<n:
    if len(h)==0:
            print(-1)
            exit()
    ld,d,l,r,c = heapq.heappop(h)
print(ld)


Measured memory_bytes: 98392
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
        int n,k;
        cin>>n>>k;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        int dp[n];
        dp[0]=0;
        //dp[1]=abs(arr[1]-arr[0]);
        for(int i=1; i<n; i++)
        {
                dp[i] = INT64_MAX;
                for(int j=1; j<=k; j++)
                {
                        if(i-j>=0)
                        {
                                dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
                        }
                }
                //cout<<dp[i]<<endl;
                //dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
        }
        cout<<dp[n-1];
        return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
const LL mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    int n;
    cin >> n;

    int A[n];
    REP(i, n) {
        cin >> A[i];
    }

    LL pre = 0;
    LL res = 0;

    REP(i, n-1) {
        int j = i + 1;
        pre += A[i];
        while (pre > mod) {
            pre -= mod;
        }
        res += (pre * A[j]) % mod;
        res = res % mod;
    }

    cout << res << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 4396
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N;
  cin >> N;
  if(N == 3 || N == 5 || N == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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


void solve(long long N){
	cout << (N*(N+1)/2) << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
def max_heapify nodes, i
  n = nodes.length

  p_i = i
  lc_i = (i + 1) * 2 - 1
  rc_i = (i + 1) * 2
  p_k = nodes[i]
  lc_k = lc_i >= 0 && lc_i <= n - 1 ? nodes[lc_i] : -Float::INFINITY
  rc_k = rc_i >= 0 && rc_i <= n - 1 ? nodes[rc_i] : -Float::INFINITY

  largest_i = p_i
  largest_k = p_k
  if largest_k < lc_k
    largest_i = lc_i
    largest_k = lc_k
  end
  if largest_k < rc_k
    largest_i = rc_i
    largest_k = rc_k
  end

  if largest_i != p_i
    nodes[largest_i], nodes[p_i] = nodes[p_i], nodes[largest_i]
    max_heapify nodes, largest_i
  end
end

n = gets.chomp.to_i
nodes = gets.chomp.split(' ').map(&:to_i)
(n - 1).downto(0) do |i|
  max_heapify nodes, i
end
puts ' ' + nodes.join(' ')


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

int n;
int a[100100];

int main(){
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	int now = 0, ans = 0;
	for(int i = 1; i < n; i++){
		if(a[i] <= a[i-1]) now++;
		else now = 0;
		ans = max(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

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

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

	string s;
	cin >> s;
	
	int n = (int) s.size();
	
	if(s[n - 1] == 's')
	{
		cout << s << "es\n";
	}
	
	else
	{
		cout << s << "s\n";
	}
	
	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<vector<int>> A(N+1,vector<int>(N+1));
  for(int i=0;i<M;i++){
    int L,R;
    cin>>L>>R;
    A[L][R]++;
  }
  for(int i=0;i<=N;i++)
    for(int j=1;j<=N;j++)
      A[i][j]+=A[i][j-1];
  for(int j=0;j<=N;j++)
    for(int i=1;i<=N;i++)
      A[i][j]+=A[i-1][j];
  for(int i=0;i<Q;i++){
    int p,q;
    cin>>p>>q;
    cout<<A[q][q]+A[p-1][p-1]-A[p-1][q]-A[q][p-1]<<endl;
  }
}

Measured memory_bytes: 5544
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		ans += n / i * (n / i + 1) / 2 * i;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3628
INF = 10**12 + 5
MAV_V = 100001

def main():
    N, W = map(int, input().split())
    dp = [[INF] * MAV_V for _ in range(N+1)]
    dp[0][0] = 0

    for i in range(1, N+1):
        w, v = map(int, input().split())
        pre_dp = dp[i-1]
        for j in range(v):
            dp[i][j] = min(pre_dp[j], w)
        for j in range(v, MAV_V):
            if pre_dp[j-v] + w <= W:
                dp[i][j] = min(pre_dp[j-v] + w, pre_dp[j])
            else:
                dp[i][j] = pre_dp[j]

    ans = [i for i, v in enumerate(dp[-1]) if v != INF]
    print(max(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 119148
#include <bits/stdc++.h>
using namespace std;
int main() {
	string n;
	while(cin >> n){
		string ans;
		switch(n[n.size() - 1]) {
			case '3':
				ans = "bon";
				break;
			case '0':
			case '1':
			case '6':
			case '8':
				ans = "pon";
				break;
			default:
				ans = "hon";
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

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

    long long x;
    cin >> x;
    long long q = x / 500;
    long long ans = 0;
    ans += q * 1000;
    x -= q * 500;
    ans += x / 5 * 5;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

SA = [0]*(N+1)
SB = [0]*(M+1)
for i in range(N):
  SA[i+1] = SA[i] + A[i]
for i in range(M):
  SB[i+1] = SB[i] + B[i]
  
ans = 0
for i in range(N+1):
  cntA = i
  rest = K - SA[i]
  if rest < 0:
    break
  cntB = bisect_right(SB, rest) - 1
  ans = max(ans, cntA+cntB)

print(ans)

Measured memory_bytes: 47564
N = int(input())
four = 0
two = 0
one = 0
for e in map(int, input().split()):
    if e % 4 == 0:
        four += 1
    elif e % 2 != 0:
        one += 1
    else:
        two += 1
if four >= one:
    print("Yes")
else:
    if two == 0 and four == one - 1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 11480
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int N_MAX=1e6;
int p_MAX=1000;
vector<int> prime;
// エラトステネスの篩(vec)
int calc_prime()
{
  bool notPrime[p_MAX];
  int n = sqrt(p_MAX)+1;
  notPrime[0]=1;
  notPrime[1]=1;
  for(int i=0;i<=n;i++){
    if(notPrime[i])
      continue;
    int m = p_MAX/i;
    for(int j=2;j<=m;j++)
      notPrime[j*i]=1;
  }
  prime.clear();
  for(int i=0;i<p_MAX;i++)
    if(!notPrime[i])
      prime.push_back(i);
  return 0;
}
int main()
{
  int n,i,j;
  int a[N_MAX];
  bool p=1,s=1,pp,ss;
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  calc_prime();
  for(i=0;i<prime.size();i++){
    pp=0;
    ss=1;
    for(j=0;j<n;j++){
      if(a[j]%prime[i]==0){
        if(pp==1)
          p=0;
        pp=1;
        while(a[j]%prime[i]==0)
          a[j]/=prime[i];
      }else{
        ss=0;
      }
    }
    if(ss==1)
      s=0;
  }
  sort(a,a+n);
  ss=1;
  for(j=1;j<n;j++){
    if(a[j]>1&&a[j]==a[j-1])
      p=0;
    else
      ss=0;
  }
  if(ss==1)
    s=0;
  if(p==1)
    cout << "pairwise coprime" << endl;
  else if(s==1)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
  return 0;
}

Measured memory_bytes: 7408
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC156
{
    /// <summary>
    /// 
    /// </summary>
    static class C
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var xs = ReadIntArray();

            var min = int.MaxValue;

            for (int i = 1; i <= 100; i++)
            {
                var sq = xs.Sum(x => (x - i) * (x - i));
                min = Math.Min(min, sq);
            }

            Console.WriteLine(min);
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Calendar cal = Calendar.getInstance();
		int m = 1;
		int d = 1;
		for(;;){
			m=sc.nextInt();
			d=sc.nextInt();
			if(m==0) break;
			cal.set(2004,m-1,d);
			switch (cal.get(Calendar.DAY_OF_WEEK)) {  
				case Calendar.MONDAY: System.out.println("Monday");break;
				case Calendar.TUESDAY: System.out.println("Tuesday");break;
				case Calendar.WEDNESDAY: System.out.println("Wednesday");break;
				case Calendar.THURSDAY: System.out.println("Thursday");break;
				case Calendar.FRIDAY: System.out.println("Friday");break;
				case Calendar.SATURDAY: System.out.println("Saturday");break;
				case Calendar.SUNDAY: System.out.println("Sunday");break;
			}
		}
	}
}

Measured memory_bytes: 15440
#include <iostream>
#include <string>

using namespace std;
int main()
{
    string S;
    cin >> S;
    int Max = 0;
    bool wasACGT = true;
    int count=0;
    for (int i = 0; i < S.length(); i++)
    {
        int j = i;
        wasACGT=true;
        count = 0;
        while (wasACGT)
        {
            
            if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T')
            {
                count++;
                j++;
                wasACGT = true;
            }
            else if (wasACGT && (S[j] != 'A' || S[j] != 'C' || S[j] != 'G' || S[j] != 'T'))
            {
                Max = max(Max, count);
                wasACGT = false;
            }
        }
    }

    cout << Max;

    return 0;
}


Measured memory_bytes: 3560
ri = lambda: list(map(int,input().split()))

n = int(input())
v = [ri() for _ in range(n)]
for i in range(n-1):
    a,t = v[i]
    aa,tt = v[i+1]
    p = max(-(-a//aa),-(-t//tt))
    if p:
        v[i+1] = [aa*p, tt*p]
print(sum(v[-1]))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) REP(i,0,n)
int n,m,h,d;
bool g[33][15][15];
bool is_ok()
{
  int x,y; x=m; y=0;
  while(y!=d){
    if(x<n && g[y][x][x+1])x++;
    else if(x>0 && g[y][x][x-1])x--;
    y++;
  }
  return x==h;
}
void gen_edge(string ss[])
{
  memset(g,0,sizeof(g));
  rep(ii,d){
    string& s=ss[ii];
    rep(i,s.size()) if(s[i]=='1')g[ii][i][i+1]=g[ii][i+1][i]=true;
  }
}
int main(void)
{
  for(;;){
    scanf("%d",&n); if(!n)break;
    scanf("%d%d%d",&m,&h,&d);
    m--; h--;
    string ss[50];
    rep(i,d)cin>>ss[i];
    gen_edge(ss);
    if(is_ok()){
      puts("0");
      continue;
    }
    rep(i,d)rep(j,n){
      if(ss[i][j]=='1')continue;
      if(j>0 && ss[i][j-1]=='1')continue;
      if(j<n-1 && ss[i][j+1]=='1')continue;
      ss[i][j]='1';
      gen_edge(ss);
      if(is_ok()){
        printf("%d %d\n",i+1,j+1);
        goto END;
      }
      ss[i][j]='0';
    }
    puts("1");
  END:;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

const lli MOD = 1e9 + 7;
lli N, M;

int main() {
	cin >> N >> M;
	//でかい方をm,小さいほうをnに
	lli m = N, n = N;
	if (N<M) m = M;
	if (N>M) n = M;
	lli ans = 0;
	//同じ数,差が1,それ以外で場合分け
	if (m == n) {
		//この場合答えは2*n!*n!
		ans = 1;
		rep1(i, n) ans = (ans*i) % MOD;
		ans = (ans*ans) % MOD;
		ans = (2 * ans) % MOD;
	}
	else if (m - n == 1) {
		//この場合答えは(n+1)*n!*n!
		ans = 1;
		rep1(i, n) ans = (ans*i) % MOD;
		ans = (ans*ans) % MOD;
		ans = ((n + 1)*ans) % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        x: u64, y: u64, z: u64
    }

    println!("{}", (x - z) / (y + z));
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i+=2) {
		int count = 0;
		for (int j = 1; j < sqrt(i); j++) {
			if (i % j == 0) {
				count++;
			}
		}
		if (count == 4) {
			ans++;
		}
	}

	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
bool isPrime(int x){
    if(x < 2) return false;
    if(x == 2) return true;
    if(x%2 == 0) return false;
    for(int i=3; i*i<=x; i++){
        if(x%i == 0) return false;
    }
    return true;
}
int main(){
    int n;
    while(cin >> n){
        if(n == 0) break;
        if(isPrime(n)) {
            cout << 0 << endl;
            continue;
        }
        int cp = n,cp1 = n;
        int left = 0,right = 0;
        int flag_left=0,flag_right=0;
        while(1){
            if(left != 0 && right != 0) break;
            if(flag_left < 1) cp--;
            if(flag_right < 1) cp1++;
            if(isPrime(cp)) {
                left = cp;
                flag_left++;
            }
            if(isPrime(cp1)){
                right = cp1;
                flag_right++;
            }
        }
        cout << right-left << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
import sys
import math
import fractions
import bisect
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''

N = int(input())
A = list(map(int,input().split()))

can = [0]*(int(1e5+10))
for n in A:
    can[n] += 1
    can[n-1] += 1
    can[n+1] += 1

ans = 0
big = 0
for i in range(int(1e5+1)):
    if big < can[i]:
        big = can[i]
        ans = i

print(big)






Measured memory_bytes: 16076