akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int D;
  cin >> D;
  const int T = 26;     // type no kazu
  vector<ll> c(T + 1);  // penalty 1-indexed
  REP(i, T) { cin >> c[i + 1]; }
  vector<vector<ll>> s(D + 1, vector<ll>(T + 1));  // 1-indexed
  REP(i, D) REP(j, T) { cin >> s[i + 1][j + 1]; }
  vector<int> t(D + 1);  // 1-indexed
  REP(i, D) { cin >> t[i + 1]; }

  int M;
  cin >> M;

  vector<ll> v(M + 1, 0);  // score after query
  vector<set<ll>> days(T + 1);
  FOR(i, 1, T + 1) {
    days[i].insert(D + 1);
    days[i].insert(0);
  }

  // score before query
  ll beforeScore = 0;
  FOR(i, 1, D + 1) {
    days[t[i]].insert(i);
    // score gain
    ll afterScore = beforeScore + s[i][t[i]];
    // penalty
    FOR(j, 1, T + 1) { afterScore -= c[j] * (i - *(++days[j].rbegin())); }
    beforeScore = afterScore;
  }
  v[0] = beforeScore;

  FOR(i, 1, M + 1) {
    int d, q;
    cin >> d >> q;

    // gain
    v[i] = v[i - 1] + s[d][q] - s[d][t[d]];

    // penalty
    days[q].insert(d);
    auto it = days[q].find(d);
    ll ld = *(--it);
    it++;
    it++;
    ll rd = *it;
    v[i] += c[q] * (rd - d) * (d - ld);

    auto it2 = days[t[d]].find(d);
    ll ld2 = *(--it2);
    it2++;
    it2++;
    ll rd2 = *(it2);
    v[i] += c[t[d]] * (rd2 - d) * (ld2 - d);

    // update info
    days[t[d]].erase(d);
    t[d] = q;
  }

  // score output
  FOR(i, 1, M + 1) { cout << v[i] << endl; }
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A < C && C < B || B < C && C < A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {

	string s; cin >> s;
	int k; cin >> k;
	int p, q;
	q = s.size();
	p = min(10, q);
	vector<string> c;
	for (int count = 1; count <= p; count++) {
		for (int j = 0; j < s.size() - count + 1; j++) {
			c.push_back(s.substr(j, count));
		}
	}

	// 辞書順の小さい順にソート
	sort(c.begin(), c.end());

	// 重複要素を削除
	c.erase(unique(c.begin(), c.end()), c.end());

	cout << c[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb() pop_back()
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 


void solve(){
 ll n,k;
  cin >> n >> k;
  vll p,q,a(n);
 rep(i,0,n) {
   cin >> a[i];
   if(a[i]>=0) p.eb(a[i]);
   else q.eb(a[i]);
 }
  
  ll s=p.size(),t=q.size(); 
  
  mint ans=1;
  
  ll f=0;
  if(s>0){
   if(n==k) f=(t%2==0?1:0);
   else f=1; 
  }else{
    f=(k%2==0?1:0);
  }
  
  
  if(!f){
    sort(all(a),[](ll x, ll y){
      return abs(x) < abs(y);
    });
    rep(i,0,k) ans*=a[i];
    cout << ans << endl;
    return;
  }
  
  sort(allr(q));
  sort(all(p));
  
  if(k%2){
   ans*=p.back();
   p.pb(); 
  }
 
  vll r;
  while(p.size()>1){
   ll x=p.back();
   p.pb();
   x*=p.back(); 
   p.pb();
   r.eb(x); 
  }
   while(q.size()>1){
   ll x=q.back();
   q.pb();
   x*=q.back(); 
   q.pb();
   r.eb(x); 
  }
  
  sort(allr(r));
  rep(i,0,k/2) {
    r[i]%=mod;
    ans*=r[i];

  }
    
  cout << ans << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 8156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		for (int i = 0; i < N; i++) {
			int num = scan.nextInt();

			if (num % 2 == 0 && !(num % 3 == 0 || num % 5 == 0)) {
				System.out.println("DENIED");
				return;
			}
		}

		System.out.println("APPROVED");
 	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN
#define itn int
#define in(x); { for (auto &to : x) cin>>to;}
#define out(x); { for (auto &to : x) cout<<to<<" ";cout<<'\n'; }

const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
ll dis(ll a,ll b)
{
    return a*a+b*b;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef Mip182
    freopen("a.in","r",stdin);
    #endif
    int n;
    cin>>n;
    ll d;
    cin>>d;
    d*=d;
    int cnt=0;
    while (n--)
    {
        ll x,y;
        cin>>x>>y;
        if (dis(x,y)<=d)
            cnt++;
    }
    cout<<cnt;


    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

Measured memory_bytes: 3648
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    t = str(input().rstrip('\n'))
    mt = n * 2
    for i in range(n):
        ts = s[-i-1:]
        tt = t[:i+1]
        if ts == tt:
            mt = min(mt, n * 2 - (i + 1))
    print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       a:i64,
       b:i64,
       c:i64,
       d:i64,
    }

    let mut ans: i64 = 0;
    ans = a * c;
    ans = max(a * d, ans);
    ans = max(ans, b * c);
    ans = max(b * d, ans);
    if b >= 0 && a <= 0 || d >= 0 && c <= 0 {
        ans = max(ans, 0);
    }

    echo!(ans);
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<map>

using namespace std;

#define maxn 1000005
#define ll long long

ll sum[1000000];

void init() {
	sum[0] = 0;
	for (int i = 1; i < maxn; i++) {
		sum[i] = sum[i - 1] + i;
	}
	return;
}


int main() {
	init();
	ll n;
	cin >> n;
	int s = upper_bound(sum, sum + maxn, n)-sum;
	ll cnt = n - sum[s - 1];
	ll count = cnt / (s - 1);
	if (count*(s - 1) < cnt) count++;
	ll ans = count + s - 1;
	cout << ans << endl;
	return 0;
}

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

int main(){
  int i = 0, a[100];
  char c[100];

  while(scanf("%s", c) != EOF){

    if(c[0] == '+') {
      a[i-2] = a[i-2] + a[i-1];
      i=i-1;
    }
    else if(c[0] == '-'){
      a[i-2] = a[i-2] - a[i-1];
      i=i-1;
    }
    else if(c[0] == '*'){
      a[i-2] = a[i-2] * a[i-1];
      i=i-1;
    }
    else{
      a[i] = atoi(c);
      i++;
    }  
  }
  printf("%d\n",a[0]);

  return 0;
}

Measured memory_bytes: 548
n=int(input())
l=[[],[]]
for i in range(n):
        a,b=map(str,input().split())
        if b=='JPY':
                l[0].append(float(a))
        else:
                l[1].append(float(a)) 
ans=0
for i in l[0]:
        ans+=i
for j in l[1]:
        ans+=j*380000
print(ans)

Measured memory_bytes: 3064
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

    # 愚直なやり方で見つけたパターンをb毎の式に落とす
    # for a in range(1, N+1):
    #     print([a % b for b in range(1, N+1)])

    ans = 0
    for b in range(K + 1, N + 1):
        # 繰り返し分
        ans += (b - K) * (N // b)
        # 半端分
        ans += max(N % b - max(K - 1, 0), 0)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9952
def gcd(m, n)
    if m < n 
        gcd(n, m)
    elsif n == 0
        m   
    else
        gcd(n, m % n)
    end 
end

def lcm(m, n)
    m * n / gcd(m, n)
end

require 'prime'

CYCLE = (1..24).reject {|x| Prime.prime?(x)}.inject {|r, x| lcm(r, x)} 

loop do
    n = gets.to_i
    break if n == 0
    cycles = {CYCLE => [0] * CYCLE}
    n.times do
        d, t, *qs = gets.split.map(&:to_i)
        qs.rotate!(t)
        if Prime.prime?(d) && d * 2 > 24
            if cycles[d]
                cycles[d] = cycles[d].zip(qs).map {|x, y| x + y}
            else
                cycles[d] = qs
            end 
        else
            qs *= CYCLE / qs.size
            cycles[CYCLE] = cycles[CYCLE].zip(qs).map {|x, y| x + y}
        end 
    end 
    p cycles.values.map(&:max).inject(:+)
end

Measured memory_bytes: 92964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();

    int n;
    vector<int> a;
    vector<int> m;

    cin >> n;

    int ans = 1;
    REP (i, n) {
        int d;
        cin >> d;
        a.eb(d);
        m.eb(abs((n-i-1) - i));

        if (i < n/2) {
            ans = ans * 2 % MOD;
        }
    }

    sort(ALL(a));
    sort(ALL(m));

    cout << (a == m ? ans : 0) << endl;
    return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}	
char mem[114514];
char t[114514];
int a[114514];
int ans[114514];
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i];
	if(n==1){
		c(a[0])
		return 0;
	}	
	ans[0]=lcm(a[0],a[1]);
	rep(1,i,n-1)ans[i]=lcm(ans[i-1],a[i+1]);	
	c(ans[n-2])
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 4007;

int cnt[N][3];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector <int> a(n);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') a[i] = 0;
    else if (s[i] == 'G') a[i] = 1;
    else a[i] = 2;
  }
  for (int i = 0; i < n; i++) {
    cnt[i][a[i]]++;
    for (int j = 0; j < 3; j++) {
      if (i > 0) cnt[i][j] += cnt[i - 1][j];
    }
  }
  auto get = [&] (int x, int l, int r) {
    if (l > r) return 0;
    if (!l) {
      return cnt[r][x];  
    } else {
      return cnt[r][x] - cnt[l - 1][x];
    }
  };
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j]) continue;
      set <int> x = {0, 1, 2};
      x.erase(a[i]);
      x.erase(a[j]);
      int y = *x.begin();
      ans += cnt[j][y] - (i ? cnt[i - 1][y] : 0);
      if ((j - i) % 2 == 0) {
        int m = (j + i) / 2;
        if (a[m] == *x.begin()) {
          ans--;
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
  int N, amari;
  cin >> N;
  amari = N % 10;

  if (amari == 2 || amari == 4 || amari == 5 || amari == 7
        || amari == 9) {
    cout << "hon" << endl;
  } else if (amari == 0 || amari == 1 ||
         amari == 6 || amari == 8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3636
from collections import Counter

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

i_l=[]
j_l=[]
for i in range(n):
  i_l.append(i+a[i])
  j_l.append(i-a[i])

ci=Counter(i_l)
cl=Counter(j_l)

ans=0
for k,v in ci.items():
  ans+=v*cl[k]

print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N, W;
    cin >> N >> W;
    int N_MAX = 110;
    int W_MAX = 10010;
    int v[N_MAX];
    int w[N_MAX];
    REP(i, N){
        cin >> v[i] >> w[i];
    }
    int DP[2][W_MAX];
    REP(i, N){
        REP(j, W+1){
            if(j<w[i]){
                DP[(i+1)&1][j] = DP[i&1][j];
            }else{
                DP[(i+1)&1][j] = max(DP[i&1][j], DP[(i+1)&1][j-w[i]]+v[i]);
            }
        }
    }
    cout << DP[N&1][W] << endl;
    return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)



int main() {
	map<string, li> cnt;
	li n;
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		cnt[s]++;
	}

	li ma = 0;
	for (auto && kv : cnt) {
		ma = max(ma, kv.second);
	}

	vector<string> res;
	for (auto && kv : cnt) {
		if (kv.second == ma) {
			res.push_back(kv.first);
		}
	}
	sort(res.begin(), res.end());
	for (auto && v : res) {
		cout << v << endl;
	}

	return 0;
}


Measured memory_bytes: 26868
import java.util.Scanner;
public class Main {
public static void main(String[] kotai) {
	Scanner sc=new Scanner(System.in);
	while(sc.hasNext()) {
	int a=sc.nextInt();
	int b=sc.nextInt();
	if(a==0 && b==0) {
		break;
	}else {
	for(int i=0;i<a;i++) {
		for(int j=0;j<b;j++) {
			if(i!=0&&i!=a-1) {
				if(j!=0 && j!=b-1) {
		   System.out.print(".");
				}
				else {
					System.out.print("#");
				}
			}
			else {
				System.out.print("#");
			}
		}
		System.out.println();
	}
	}
	System.out.println();
	}
}
}


Measured memory_bytes: 34072
h, w, d = map(int, input().split())
a_dict = dict()
for i in range(h):
    A = list(map(int, input().split()))
    for j in range(w):
        a_dict[A[j]] = [i+1, j+1]
q = int(input())
query = []
for i in range(q):
    query.append(list(map(int, input().split())))

a_list = [0]*(h*w+1)
for i in range(1, h*w+1):
    if i + d <= h*w:
        pos = a_dict[i]
        d_pos = a_dict[i+d]
        a_list[i+d] += a_list[i] + abs(d_pos[0]-pos[0]) + abs(d_pos[1]-pos[1])
for i in range(q):
    l, r = query[i]
    print(a_list[r] - a_list[l])


Measured memory_bytes: 50152
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [10 ** 9] * n
dp[0] = 0

for i in range(1, n):
    k_max = min(i, k)
    for j in range(1, k_max+1):
        dp[i] = min(dp[i], abs(h[i] - h[i-j]) + dp[i-j])
print(dp[n-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> F(N, vector<int>(10, 0));
    vector<vector<int>> P(N, vector<int>(11, 0));
    rep(i, N) rep(j, 10) cin >> F[i][j];
    rep(i, N) rep(j, 11) cin >> P[i][j];

    int x = INT_MIN;
    rep(k, 1, 1024) {
        int prof = 0;
        rep(i, N) {
            int m = 0;
            rep(j, 10) if((k >> j & 1) && F[i][j]) m++;
            prof += P[i][m];
        }
        chmax(x, prof);
    }
    cout << x << endl;
}

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

int main(void){
        int n, m;
        cin >> n >> m;
        vector<int> s(m), c(m), ans(n, -1);
        for(int i = 0; i < m; i++) cin >> s[i] >> c[i];
        for(int i = 0; i < m; i++){
                if(ans[s[i]-1] == -1 || ans[s[i]-1] == c[i]){
                        ans[s[i]-1] = c[i];
                } else {
                        cout << -1 << endl;
                        return 0;
                }
        }
        if(ans[0] == -1 and n > 1){
                ans[0] = 1;
                for(int i = 0; i < n; i++) {
                        if(ans[i] == -1) ans[i] = 0;
                        cout << ans[i];
                }
                cout << endl;
                return 0;
        }
        if((ans[0] != -1 and ans[0] != 0) or n == 1){
                for(int i = 0; i < n; i++) {
                        if(ans[i] == -1) ans[i] = 0;
                        cout << ans[i];
                }
                cout << endl;
        } else {
                cout << -1 << endl;
        }
        return 0;
}


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

using namespace std;

int main(){
  int x,i,ret;
  cin >> x;
  ret = 1;
  for(i=2;i*i<=x;i++){
    int ans=i*i;
    while(ans*i<=x){
      ans*=i;
    }
    ret = max(ret,ans);
  }
  cout << ret << endl;
  return 0;
}


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

using namespace std;

#define ll long long

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	for (int i = 0; i < k - 1; i++) cout << s[i];
	cout << (s[k - 1] == 'A' ? 'a' : s[k - 1] == 'B' ? 'b' : 'c');
	for (int i = k; i < n; i++) cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N,M;
int A[1010],B[1010];
int checkA[1145141]={0};
int checkB[1145141]={0};
ll cntA[1145141]={0};
ll cntB[1145141]={0};
int main(){
	cin>>N>>M;
	rep(i,N){
		cin>>A[i];
		checkA[A[i]]++;
	}
	sort(A,A+N);
	rep(i,M){
		cin>>B[i];
		checkB[B[i]]++;
	}
	ll kei=0;
	for(int i=1145100;i>=0;i--){
		cntA[i]=cntA[i+1]+checkA[i];
		cntB[i]=cntB[i+1]+checkB[i];
	}
	sort(B,B+M);
	bool flag=true;
	if(A[N-1]!=N*M)flag=false;
	if(B[M-1]!=N*M)flag=false;
	rep(i,N-1)if(A[i]==A[i+1])flag=false;
	rep(i,M-1)if(B[i]==B[i+1])flag=false;
	if(flag){
		ll ans=1;
		ll f=1;
		for(int hoge=N*M;hoge>=1;hoge--){
			if(hoge==N*M)ans*=1;
			else{
	
				if(checkA[hoge]+checkB[hoge]==2){
					f=1;
				}else if(checkA[hoge]+checkB[hoge]==1){
					if(checkA[hoge]==1){
						f=cntB[hoge];
					}else{
						f=cntA[hoge];
					}
				}else{
					f=cntA[hoge]*cntB[hoge]-(N*M-hoge);
				}
				//cout<<hoge<<" "<<f<<endl;
				ans = (ans*(ll)f)%MOD;
			}
		}
		cout<<ans<<endl;
	}else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 22784
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> ans(n);
    for (int i = 0; i < q; ++i) {
        int x;
        scanf("%d", &x);
        ans[x-1]++;
    }
    for (int i = 0; i < n; ++i) {
        puts(ans[i]-q+k > 0 ? "Yes" : "No");
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-8
#define inf INT_MAX
#define mod 1000000009
using namespace std;

vector<pair<int, int> > g[100000];
int ans[100000];
void dfs(int v, int p, int c) {
	ans[v] = c;
	for (auto i : g[v])
		if (i.first != p)
			dfs(i.first, v, (c ^ i.second));
}

int main() {
	speed;
	int n, u, v, w;
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		cin >> u >> v >> w;
		--u, --v;
		g[u].push_back({ v, w % 2 });
		g[v].push_back({ u, w % 2 });
	}
	dfs(0, 0, 0);
	for (int i = 0; i < n; ++i)
		cout << ans[i] << '\n';
	return 0;
}

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

int main()
{
    /*A
    int a,b;
    cin>>a>>b;
    if(a-2*b>0)
    cout<<a-2*b<<endl;
    else
    {
        cout<<0<<endl;
    }
    */

   /*B
   int n;
   cin>>n;
   int sum=0;
   vector <int> a(n);
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }

   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           sum += a[i]*a[j];
       }
   }

    cout<<sum<<endl;
   */

    //C
    int n;
    int count=1;
    char c,x;
    cin>>n;

    string str;

    for(int i=0;i<n;i++)
    {   
        cin>>c;
        str.push_back(c);
    }

    for(int i=0;i<n-1;i++)
    {
        x = str[i];
        if(x!=str[i+1])
        {
            count++;
            x = str[i+1];
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	// Code for C - Flip,Flip, and Flip......
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	var A, B int
	if N == 1 {
		A = 1
	} else {
		A = N - 2
	}

	if M == 1 {
		B = 1
	} else {
		B = M - 2
	}

	fmt.Println(A * B)

}


Measured memory_bytes: 1832
#include<iostream>
using namespace std;
int main() {
	int a, b, date[11111],date2[11111],dai,kk,ans;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			goto a;
		}
		ans = 0;
		for (int i = 1; i <= a; i++) {
			cin >> date[i];
			ans += date[i];
		}
		for (int i = 1; i <= a; i++) {
			dai = 0;
			for (int z = 1; z <= a; z++) {
				if (dai <= date[z]) {
					dai = date[z];
					kk = z;
				}
			}
			date[kk] = 0;
			date2[i] = dai;
		}
		int ok = 0;
		while(ok<= a-b) {
			ok = ok + b;
			ans -= date2[ok];
		}
		cout << ans << endl;
	}
a:;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,m,sum=0,temp=10000000;
  cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>m;
    temp=min(temp,m);
    sum+=m;
  }
  x-=sum;
  cout<<n+x/temp<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5 ;
const int INF = 1e9 + 1e5 + 2;
const int mod= 1e9+7;
#define eps 1e-15
#define F first
#define S second
typedef long long ll;
int main()
{
    string s;

    cin>>s;
    for (int i=0; i<s.size(); ++i)
    {
        if (s[i]=='7')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";





    
}

Measured memory_bytes: 3624
/*
                ┈┈╱▔▔▔▔▔▔▔▏ 
                ┈╱╭▏╮ ╭┻┻╮╭┻┻╮╭▏ 
                ▕╮╰▏╯┃╭╮┃┃╭╮┃╰▏ 
                ▕╯┈▏┈┗┻┻┛┗┻┻┻╮▏ 
                ▕╭╮▏╮┈┈┈┈┏━━━╯▏
                ▕╰╯▏╯╰┳┳┳┳┳┳╯╭▏ 
                ▕┈╭▏╭╮┃┗┛┗┛┃┈╰▏ 
                ▕┈╰▏╰╯╰━━━━╯┈┈▏

████████╗██╗░░░██╗███╗░░██╗███████╗░█████╗░██╗░░██╗██╗
╚══██╔══╝██║░░░██║████╗░██║██╔════╝██╔══██╗██║░░██║██║
░░░██║░░░██║░░░██║██╔██╗██║█████╗░░██║░░╚═╝███████║██║
░░░██║░░░██║░░░██║██║╚████║██╔══╝░░██║░░██╗██╔══██║██║
░░░██║░░░╚██████╔╝██║░╚███║███████╗╚█████╔╝██║░░██║██║
░░░╚═╝░░░░╚═════╝░╚═╝░░╚══╝╚══════╝░╚════╝░╚═╝░░╚═╝╚═╝
*/

#include<bits/stdc++.h>
using namespace std;

#define INF 1000000005
#define mod ((int)1e9+7)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define f0(i,n) for(i = 0; i < ( n ); i ++)
#define f1(i,n) for(i = 1; i <= ( n ); i ++)
#define f(i,m,n) for(int i = ( m ); i <= ( n ); i ++)
#define run ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl cout<<"\n";

typedef long long int ll;
typedef unsigned long long int ull;

vector<vector<ll> > dp;

int main()
{
    int n;
    cin>>n;
    int cap;
    cin>>cap;
    vector<ll> w;
    vector<ll> p;
    f(i,0,n-1)
    {
        ll a,b;
        cin>>a>>b;
        w.pb(a);
        p.pb(b);
    }
    vector<ll> temp;
    f(i,0,cap)
        temp.pb(-1);
    f(i,0,n)
        dp.pb(temp);
    f(i,0,n)
    {
        f(j,0,cap)
            if(i==0||j==0)  dp[i][j]=0;
    }
    f(i,1,n)
    {
        f(j,1,cap)
        {
            if(j-w[i-1]<0) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],(dp[i-1][j-w[i-1]]+p[i-1]));
        }
    }
    cout<<dp[n][cap];
    return 0;
}

Measured memory_bytes: 80376
N = int(input())
A = list(map(int,input().split()))
minus = 0
for i in range(N):
  if A[i] < 0:
    minus += 1
    A[i] = abs(A[i])
if minus%2 == 0:
  print(sum(A))
else:
  print(sum(A)-(2*min(A)))

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

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
int main(){
  ll dp[105][100005];
  ll n,k;cin >> n >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<=n;i++){
    dp[i][0]=1;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++){
      dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
      if(j-a[i-1]-1>=0){
        dp[i][j]=(dp[i][j]+mod-dp[i-1][j-a[i-1]-1])%mod;
      }
    }
  }
  cout << dp[n][k] << endl;
}

Measured memory_bytes: 80128
import java.util.Scanner;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();

    if ((a + b) % 2 == 0){
      System.out.println((a + b) /2) ;
    }
    else {
      System.out.println((a + b) / 2 + 1);
    }
  }
}


Measured memory_bytes: 21716
macro_rules! input {
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

    ($iter:expr, chars) => {
        read_value!($iter, String).chars()
    };

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

fn main() {
    input! {
        s: String
    }

    if s == "AAA" || s == "BBB" {
        println!("No");
    } else {
        println!("Yes");
    }
}



Measured memory_bytes: 4352
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;

int N,M,head[maxm],tot;
int DP[maxm];
bool Visit[maxm];

struct edge{
	int To;
	int Next;
	# define To(x) Edge[x].To
	# define Next(x) Edge[x].Next
}Edge[maxm<<1];

inline void Add_Edge(int From,int To){Edge[++tot]=(edge){To,head[From]},head[From]=tot;return;}

void Dfs(int now){
	if(Visit[now]) return;
	Visit[now]=true;
	for(int i=head[now];i;i=Next(i)){
		Dfs(To(i));
		DP[now]=max(DP[now],DP[To(i)]);
	}
	DP[now]++;
	return;
}

int main(){
	register int i,Ans;
	int x,y;
	scanf("%d%d",&N,&M);
	for(i=1;i<=M;i++){
		scanf("%d%d",&x,&y);
		Add_Edge(x,y);
	}
	for(i=1;i<=N;i++){
		if(Visit[i]) continue;
		Dfs(i);
	}
	for(i=1;i<=N;i++){
		Ans=max(Ans,DP[i]);
	}
	if(Ans==0) Ans=1;
	printf("%d",Ans-1);
	return 0;
}

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

using namespace std;

int draw()
{
    int x,y;
    cin>>x>>y;

    if(x==0 && y==0)
        return 0;
    else
        for(int i = 0; i<x; i++)
        {
            for(int j = 0; j<y; j++)
            {
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    draw();
}

int main()
{

    draw();
    return 0;
}




Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define open freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
using namespace std; typedef long long ll; typedef long double ld; mt19937 rnd(time(0));

#define int ll

void solve(){
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++){
        int m = n;
        if ((m - 1) % i == 0){
            cnt += 2 - ((m - 1) / i == i);
        }else{
            while(m % i == 0)
                m /= i;
            cnt += ((m - 1) % i == 0);
        }
    }
    cout << cnt << endl;
}

signed main(){
    ios;
    // open;
    ll t = 1;
    // cin >> t;
    cout.precision(16);
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long r=0,g=0,b=0;
		String text = sc.next();
		char str[] = text.toCharArray();
		for(int i=0;i<n;i++){
			switch(str[i]){
				case 'R':
					r++;
					break;
				case 'G':
					g++;
					break;
				case 'B':
					b++;
					break;
			}
		}
		long pair = r*g*b;
		for(int i=1;i<n;i++){
			for(int j=0;j<i;j++){
				if(i+(i-j)<n){
					if(str[i]!=str[j]&&str[i]!=str[i+(i-j)]&&str[j]!=str[i+(i-j)])
					pair--;
				}
			}
		}
		System.out.println(pair);
	}
}


Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(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 fs first
#define sc second

int main(){
    int n,m;
    while(cin>>n>>m,n){
        int r,q;
        cin>>r;
        map<int,vi> user;
        rep(i,r){
            int a,b,c,d; cin>>a>>b>>c>>d;
            if(user.find(c)==user.end()){
                user[c]=vi(721,0);
            }
            if(d==1){
                user[c][a-540]++;
            }else{
                user[c][a-540]--;
            }
        }
        for(auto &p : user)partial_sum(all(p.sc),p.sc.begin());
        cin>>q;
        rep(i,q){
            int a,b,c,d=0; cin>>a>>b>>c;
            a-=540,b-=540;
            if(user.find(c)!=user.end()){
                range(j,a,b){
                    d+=user[c][j]?1:0;
                }
            }
            cout<<d<<endl;
        }
    }
}

Measured memory_bytes: 3492
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
int n,i,j;
ll ans=llinf,a[nmax];
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    for(i=1;i<n;i++)if(abs(((a[n]+1)/2)-a[i])<ans)ans=abs(((a[n]+1)/2)-a[i]),j=i;
    cout<<a[n]<<" "<<a[j]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct UnionFind {
private:
    vector<ll> data;
public:
    UnionFind(ll sz) {
        data.assign(sz, -1);
    }
    bool unite(ll x, ll y) {
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }
    ll find(ll k) {
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }
    ll size(ll k){
        return(-data[find(k)]);
    }
};

int main () {

    ll n; cin >>n;
    ll m; cin >>m;
    vector<ll> a(m);
    vector<ll> b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[m-1-i] >> b[m-1-i];
        a[m-1-i] -= 1;
        b[m-1-i] -= 1;
    }

    UnionFind tree(n);
    vector<ll> ans;
    ll res = n *(n-1)/2;
    ans.push_back(res);
    for (int i = 0; i < m-1; i++) {
        ll n1 = tree.size(a[i]);
        ll n2 = tree.size(b[i]);
        if(tree.unite(a[i], b[i])) {
            res -= n1*n2;
            ans.push_back(res);
        } else {
            ans.push_back(res);
        }
    }

    for (int i = 0; i < m; i++) {
        cout << ans[m-1-i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define int long long 
using namespace std ;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n ; cin>>n;
	vector<vector<int>>dp(n,vector<int>(3,0));
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(i==0){
			dp[0][0]=a;
			dp[0][1]=b;
			dp[0][2]=c;
			continue;
		}
		dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2] = max(dp[i-1][1],dp[i-1][0])+c;
	}
	cout<<(*max_element(dp[n-1].begin(),dp.back().end()))<<endl;

	return 0;
}


Measured memory_bytes: 5760
package main

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

var sc = bufio.NewScanner(os.Stdin)

// utils
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

// func max(a, b int) int {
// 	return int(math.Max(float64(a), float64(b)))
// }

// func min(a, b int) int {
// 	return int(math.Min(float64(a), float64(b)))
// }

// func abs(a, b int) int {
// 	return int(math.Abs(float64(a) - float64(b)))
// }

// //data types

// type pair struct {
// 	first  int
// 	second int
// }

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	for i := 0; i < n; i++ {
		v := nextInt()
		if v%2 == 0 {
			if v%3 != 0 && v%5 != 0 {
				fmt.Print("DENIED")
				return
			}
		}
	}
	fmt.Print("APPROVED")
}


Measured memory_bytes: 640
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

vector<vector<ll>> multiply(vector<vector<ll>> A, vector<vector<ll>> B)
{
    int n = A.size();
    vector<vector<ll>> res(n, vector<ll>(n, 0));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            for(int x = 0; x < n; x++)
                res[i][j] = (res[i][j] + A[i][x]*B[x][j]) % mod;
        }
    }
    return res;
}
vector<vector<ll>> power(vector<vector<ll>> mat, ll exp)
{
    if(exp == 1)
        return mat;
    vector<vector<ll>> res = power(mat, exp/2);
    if(exp&1)
        return multiply(multiply(mat,res),res);
    else return multiply(res,res);
}

ll solve(vector<vector<ll>>& adj, ll k, int n)
{
    vector<vector<ll>> ak = power(adj, k);
    ll ans = 0;
    for(int i = 0; i <n; i++)
        for(int j = 0; j <n; j++)
            ans = (ans + ak[i][j]) % mod;
    return ans;
}

int main() {
   int n; 
   ll k;
   cin >> n >> k;
   vector<vector<ll>> adj(n, vector<ll>(n));
   for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> adj[i][j];
   cout << solve(adj, k, n);
   return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

typedef long long ll;
ll A, B, C;

using namespace std;

int main(){
	scanf("%lld%lld%lld", &A, &B, &C);
	if(A%2==0 || B%2==0 || C%2==0){
		printf("0");
		return 0;
	}
	printf("%lld", min(A*B, min(B*C, C*A)));
	return 0;
}

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

int main() {
    int n,a[100*1000],k;
    cin >> n >> k;
    for (int i=0; i<n; ++i) cin >> a[i];
    sort(a,a+n);
    int res = 0;
    for (int i=0; i<k; ++i) res += a[i];
    cout << res << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

pair<int, int> a[51][51];

int main() {
    int x,a;
    cin >> x >> a;
    if (x < a) cout << "0" << endl;
    else cout << "10" << endl;
    return 0;
}

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

int main() {
    int N, M;
    cin>>N>>M;
    vector<int> road(N);
    for(int i=0; i<M; i++) {
        int a,b;
        cin>>a>>b;
        road[a-1]++;
        road[b-1]++;
    }
    for(int i=0; i<N; i++)
        cout<<road[i]<<endl;

    return 0;
}

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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ab = 2*c;
    int ans = 0;
    if(a+b>ab){
        while(x>0 && y>0){
            x--;
            y--;
            ans += ab;
        }
        if(x>0){
            if(a>ab){
                while(x>0){
                    x--;
                    ans += ab;
                }
            }else{
                while(x>0){
                    x--;
                    ans += a;
                }
            }
        }else if(y>0){
            if(b>ab){
                while(y>0){
                    y--;
                    ans += ab;
                }
            }else{
                while(y>0){
                    y--;
                    ans += b;
                }
            }
        }
    }else{
        ans = a*x + b*y;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
ans = 0
if n < 105:
    print(0)
    exit
else:
    for i in range(105, n+1, 2):
        cnt = 0
        for q in range(1,i+1):
            if i % q == 0:
                cnt += 1
        if cnt == 8:
            ans += 1
    print(ans)

Measured memory_bytes: 9184