akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    long long h[N];
    long long dp[N];



    for(long long i =0 ; i < N; i++) {
        cin >> h[i];
        //cout << "h" << h[i] << endl;
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(long long i = 2; i < N; i++) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]) );
    }

    cout << dp[N-1];

    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    s = input()
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main () {
  int K, a, b;
  cin >> K;
  
  if (K%2 == 0) {
    a = K/2;
    b = K/2;
  }
  if (K%2 == 1) {
    a = K/2+1;
    b = K/2;
  }
  cout << a*b << endl;
}

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

const int maxn=105;
int n,m;
char s[maxn][maxn];
int dp[maxn][maxn];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	for(int i=0;i<n;i++)for(int j=0;j<m;j++){
		if(i==0&&j==0)dp[i][j]=(s[i][j]=='#');
		else{
			dp[i][j]=n*m;
			if(i)dp[i][j]=min(dp[i][j],dp[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#'));
			if(j)dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#'));
		}
	}
	printf("%d\n",dp[n-1][m-1]);
	return 0;
}

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

int main(){
    int m, nmin, nmax;
    while(cin >> m >> nmin >> nmax && m > 0 || nmin > 0 || nmax > 0){
        vector<int> a(m);
        for(int i = 0; i < m; i++){
            cin >> a[i];
        }
        int ans = 0;
        int tmp;
        for(int i = nmin; i <= nmax; i++){
            if(a[i - 1] - a[i] >= ans){
                ans = a[i - 1] - a[i];
                tmp = i;
            }
        }
        cout << tmp << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
a = list(map(str,(input())))
b = list(map(str,(input())))
c = list(map(str,(input())))

card = a[0]

for i in range(len(a) + len(b) + len(c)):
    if card == 'a':
        if a == []:
            print("A")
            break
        else:
            card = a[0]
            a.pop(0)

    elif card == 'b':
        if b == []:
            print("B")
            break
        else:
            card = b[0]
            b.pop(0)

    else:
        if c == []:
            print("C")
            break
        else:
            card = c[0]
            c.pop(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];

    // 不可能判定
    int e[60][60];
    rep(i,60)rep(j,60)e[i][j] = 0;
    rep(i,51){
        srep(j,1,51){
            e[i][i%j] = 1;
        }
    }

    int f[60][60];
    rep(i,60)rep(j,60)f[i][j] = 0;
    rep(i,60){
        queue<int> que;
        que.push(i);
        f[i][i] = 1;
        while(que.size()>0){
            int x = que.front();
            que.pop();
            rep(j,60){
                if(e[x][j] && f[i][j] == 0){
                    f[i][j] = 1;
                    que.push(j);
                }
            }
        }
    }

    rep(i,n){
        if(f[a[i]][b[i]] == 0){
            cout << -1 << endl;
            return 0;
        }
    }

    int keep[60] = {};
    drep(i,50){
        int use[60] = {};
        rep(j,60) use[j] = keep[j];
        srep(j,1,i+1){
            use[j] = 1;
        }
        rep(j,60)rep(k,60)e[j][k] = 0;
        rep(j,51){
            srep(k,1,51){
                if(use[k]) e[j][j%k] = 1;
            }
        }
        rep(j,60)rep(k,60)f[j][k] = 0;
        rep(j,60){
            queue<int> que;
            que.push(j);
            f[j][j] = 1;
            while(que.size()>0){
                int x = que.front();
                que.pop();
                rep(k,60){
                    if(e[x][k] && f[j][k] == 0){
                        f[j][k] = 1;
                        que.push(k);
                    }
                }
            }
        }
        int ng = 0;
        rep(j,n){
            if(f[a[j]][b[j]] == 0){
                ng = 1;
                break;
            }
        }
        if(ng) keep[i+1] = 1;
    }

    ll ans = 0;
    rep(i,60){
        if(keep[i]){
            ans += (1LL << i);
        }
    }
    cout << ans << endl;
    return 0;
}




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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	int count = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	while (true) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 != 0) {
				cout << count << endl;
				return 0;
			}
			a[i] /= 2;
		}
		count++;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#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;i>=0;i--)
#define INF 100000005
#define MAX 1002
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[100];
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	rep(i,n)scanf("%d", &a[i]);
	for(int k = 1;k <= m;k++){
		for(int i = 0;i < n-1;i++){
			if(a[i]%k > a[i+1]%k)swap(a[i], a[i+1]);
		}
	}
	rep(i,n)printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 3188
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		String str = s.next();
		if(str.charAt(0)==str.charAt(3) &&
				str.charAt(1)==str.charAt(2) &&
				str.charAt(0)!=str.charAt(1) ) {
			System.out.println("Yes");
		}else if(str.charAt(0)==str.charAt(2) &&
				str.charAt(1)==str.charAt(3) &&
				str.charAt(0)!=str.charAt(1) ) {
			System.out.println("Yes");
		}else if(str.charAt(0)==str.charAt(1) &&
				str.charAt(2)==str.charAt(3) &&
				str.charAt(1)!=str.charAt(2) ) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,m;
    cin>>n>>m;
    long long int fl,fr;
    long long int l,r;
    cin>>l>>r;
    fl=l;fr=r;
    m--;
    while(m--){
    	cin>>l>>r;
    	if(l>fl){
    		fl=l;
		}
		if(r<fr){
			fr=r;
		}
	}
	if(fr<fl){
		cout<<"0";
	}
	else{
		long long int ans=fr-fl+1;
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    int count = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 2 != 0) count++;
    }
    cout << setprecision(10) << count / (double)N << endl;

    return 0;
}

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

#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;

vector<pair<int, int>> steps = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};

int n, m, k;

bool check(int i, int j) {
    return (i >= 0 && i < n && j >= 0 && j < m);
}

void solve() {
    cin >> n >> m >> k;
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2; --x1; --x2; --y1; --y2;
    vector<vector<char>> tb(n, vector<char> (m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) cin >> tb[i][j];
    }
    vector<vector<vector<pair<int, int>>>> dist(n, vector<vector<pair<int, int>>>(m, vector<pair<int, int>>(4, {int(1e9), k})));
    vector<vector<vector<bool>>> used(n, vector<vector<bool>>(m, vector<bool>(4)));
    dist[x1][y1][0] = {0, k};
    set<pair<pair<int, pair<int, int>>, pair<int, int>>> q;
    q.insert({{0, {k, 0}}, {x1, y1}});
    while (!q.empty()) {
        auto top = *q.begin();
        q.erase(q.begin());
        int i = top.second.first, j = top.second.second;
        pair<int, pair<int, int>> way = top.first;
        if (used[i][j][way.second.second]) continue;
        if (i == x2 && j == y2) break;
         used[i][j][way.second.second] = true;
        //cout << "v: " << i << ' ' << j << ' ' << way.second.first << ' ' << way.second.second << endl;
        for (int t = 0; t < 4; ++t) {
            int newi = i + steps[t].first, newj = j + steps[t].second;
            auto newway = way;
            if (t == newway.second.second && newway.second.first < k) {
                newway.second.first++;
            } else {
                newway.first++;
                newway.second = {1, t};
            }
            pair<int, int> newone = {newway.first, newway.second.first};
            if (check(newi, newj) && tb[newi][newj] != '@' && dist[newi][newj][newway.second.second] > newone) {
                dist[newi][newj][newway.second.second] = newone;
                q.insert({newway, {newi, newj}});
            }
        }
    }
    int ans = dist[x2][y2][0].first;
    ans = min(ans, dist[x2][y2][1].first);
    ans = min(ans, dist[x2][y2][2].first);
    ans = min(ans, dist[x2][y2][3].first);
    if (ans == int(1e9)) cout << -1 << "\n";
    else cout << ans << "\n";
}

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

Measured memory_bytes: 215228
#![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! {
       N: usize,
    }
    let mut a = vec![];
    for _ in 0..N {
        input! {
            b:i64,
            c:i64,
        }
        a.push((b + c, b, c));
    }
    a.sort_by_key(|x| x.0);
    a.reverse();
    let mut d = 0;
    let mut e = 0;
    for i in 0..N {
        let (_, b, c) = a[i];
        if i % 2 == 0 {
            d += b;
        } else {
            e += c;
        }
    }

    let mut ans: i64 = 0;
    ans = d - e;

    echo!(ans);
}


Measured memory_bytes: 7264
/*
    author: blue_matrix
*/
#include <bits/stdc++.h>
using namespace std;

#define n_l '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#define ll long long
void dfs(vector<string> &v,vector<vector<bool>> &vis,ll i,ll j,ll n,ll m)
{
    vis[i][j]=true;
    if(i>n || i<1 || j>m || j<1)
        return ;
    
    // cout<<" ("<<i<<" "<<j<<") ";
    for(ll k=-1;k<=1;k++)
    {
        for(ll p=-1;p<=1;p++)
        {
            if(p==0 || k==0)
            {
                if(vis[i+k][j+p]==false and v[i+k][j+p]=='.' )
                    dfs(v,vis,i+k,j+p,n,m);
            }
        }
    }
    return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll n=s.size();
    cout<<s.substr(0,min(k,n));
    if(k<n)
    cout<<"..."<<endl;
    return 0;
}

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

using namespace std;

class DSU
{
public:
    DSU(int n)
    {
        N = n;
        p = new int[n + 1];
        sz = new int[n + 1];
        for (int i = 1; i <= n; i++)
        {
            p[i] = i, sz[i] = 1;
        }
    }
    int find_set(int v)
    {
        return (p[v] == v) ? v : p[v] = find_set(p[v]);
    }
    void union_set(int a, int b)
    {
        a = find_set(a);
        b = find_set(b);
        if (a == b) return ;
        if (sz[a] < sz[b]) swap(a, b);
        p[b] = a;
        sz[a] += sz[b];
    }
    int Size_set(int v)
    {
        v = find_set(v);
        return sz[v];
    }
private:
    int N, *p, *sz;
};

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector < vector <int> > Friend(n + 1), Block(n + 1);
    DSU dsu(n);
    for (int i = 0, u, v; i < m; i++)
    {
        cin >> u >> v;
        dsu.union_set(u, v);
        Friend[u].push_back(v);
        Friend[v].push_back(u);
    }
    for (int i = 0, u, v; i < k; i++)
    {
        cin >> u >> v;
        Block[u].push_back(v);
        Friend[v].push_back(u);
    }
    for (int i = 1; i <= n; i++)
    {
        set <int> st;
        st.insert(i);
        for (int v : Friend[i])
            st.insert(v);
        for (int v : Block[i])
            st.insert(v);
        int ret = dsu.Size_set(i);
        for (int v : st)
        {
            if (dsu.find_set(i) == dsu.find_set(v)) ret--;
        }
        cout << ret << " ";
    }
}

Measured memory_bytes: 16504
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;cin>>n;
    int t[n];
    for(int i = 0;i<n;i++) cin>>t[i];
    sort(t,t+n,greater<int>());
    t[0]/=2;
    int g = 0;
    for(int i = 0;i<n;i++){
      g+= t[i];
    }
    cout<<g;
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  string s;
  int x,y;
  cin>>s>>x>>y;
  vector<int> a,b;
  bool f=1;
  int tmp=0;
  for(auto itr=s.begin();itr !=s.end();itr++)
  {
    if(*itr=='F'){tmp++;}
    else {
      if(f){a.push_back(tmp);}
      else{b.push_back(tmp);}
      f=!f;
    tmp=0;
  }

  }
  if(f){a.push_back(tmp);}
  else{b.push_back(tmp);}
  x-=a[0];
  x=abs(x);
  y=abs(y);
  a.erase(a.begin());
  int suma=0,sumb=0;
  for(auto itr=a.begin();itr !=a.end();itr++)
  {
    suma+=*itr;
  }
  for(auto itr=b.begin();itr !=b.end();itr++)
  {
    sumb+=*itr;
  }
  int flag=0;
  if((suma-x)%2 or (sumb-y)%2 or suma<x or sumb<y){flag=0;}
  else
  {
    x=(suma-x)/2;
    y=(sumb-y)/2;
    vector<int> dpx(8001),dpy(8001);
    //for(int i=0;i<8001;i++){dpx[i]=0;dpy[i]=0;}
    dpx[0]=1;dpx[suma]=1;
    dpy[0]=1;dpy[sumb]=1;
    for(auto itr1=a.begin();itr1 !=a.end();itr1++)
    {
      for(int i=x-*itr1;i>-1;i--)
      {
        if(dpx[i]==1){dpx[i+*itr1]=1;}
      }
      if(dpx[x]!=0){flag+=1;break;}

    }
    if(a.size()==0 and x==0){flag+=1;}
    for(auto itr2=b.begin();itr2 !=b.end();itr2++)
    {
      for(int i=y-*itr2;i>-1;i--)
      {
        if(dpy[i]==1){dpy[i+*itr2]=1;}
      }
      if(dpy[y]!=0){flag+=1;break;}
    }
    if(b.size()==0 and y==0){flag+=1;}
  }
  cout<<yn(flag>=2)<<endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      
      double[] p= new double[n];
      double max = 0;
      double sum = 0;
      for(int i = 0;i<n;i++){
        p[i] = ((double)(sc.nextInt())/2.0) + 0.5;
      }
      for(int i = 0;i<n;i++){
          sum+=p[i];
          if(i>=k){
            sum-=p[i-k];
          }
          if(sum>max){
            max=sum;          
          }
      }
      System.out.println(max);
    }
}


Measured memory_bytes: 81420
import Control.Monad
import Data.List

solve :: Int -> [(Int, Int)] -> Int
solve k ((a, b):rs)
  | k <= b = a
  | True = solve (k - b) rs


main :: IO ()
main = do
  n:k:_ <- fmap (\x -> read x :: Int) <$> words <$> getLine
  l <- fmap ((\[a, b] -> (a, b)) . (fmap (\x -> read x :: Int)) . words) <$> replicateM n getLine
  print $ solve k $ sort l


Measured memory_bytes: 92540
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int d,n;cin>>d>>n;
	int a=1;rep(i,d)a*=100;
	int cnt=0;
	for(int i=1;;i++){
		if(i%100==0)continue;
		cnt++;
		if(cnt==n){
			cout<<a*i<<endl;
			return 0;
		}
	}
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

const int MAX_N = 100;
int n;
ll in[MAX_N];
ll dp[MAX_N+1][21];

int main()
{
  cin >> n;
  rep(i, n) cin >> in[i];

  dp[0][in[0]] = 1LL;
  rep(i, n) rep(j, 21){
    if(j-in[i+1] >=  0LL) dp[i+1][j-in[i+1]] += dp[i][j];
    if(j+in[i+1] <= 20LL) dp[i+1][j+in[i+1]] += dp[i][j];
  }

  cout << dp[n-2][in[n-1]] << endl;

  return 0;
}

Measured memory_bytes: 1180
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
struct BinaryIndexedTree {
	int n;
	vector<int>d;
	BinaryIndexedTree(int m) :n(m) {
		d.assign(n + 1, 0);
	}
	void add(int i, T x) {
		for (int j = i; j <= n; j += j&(-j))d[j] += x;
	}
	T sum(int i) {
		T ret(0);
		for (int j = i; j > 0; j -= j&(-j))ret += d[j];
		return ret;
	}
	T sum(int s, int t) {
		return sum(t) - sum(s - 1);
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	BinaryIndexedTree<int> bit(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)cout << bit.sum(x, y) << endl;
		else bit.add(x, y);
	}
	return 0;
}

Measured memory_bytes: 3268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}

	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] l=new int[n];
		int[] r=new int[n];
		int ans=0;
		for(int i=0;i<n;i++) {
			l[i]=sc.nextInt();
			r[i]=sc.nextInt();
			ans+=r[i]-l[i]+1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26596
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    X,Y,E = LI()

    edge = [set() for _ in range(X+Y+2)]

    for _ in range(E):
        a,b = LI()
        i = a + 1
        j = b + X + 1
        edge[i].add(j)
    for i in range(1,X+1):
        edge[0].add(i)
    for j in range(X+1,X+Y+1):
        edge[j].add(X+Y+1)

    ans = 0
    while True:
        node = [-2] * (X + Y + 2)
        node[0] = -1
        q = collections.deque()
        q.append(0)
        while q:
            u = q.pop()
            for v in edge[u]:
                if v == X + Y + 1:
                    ans += 1
                    node[v] = u
                    break
                if node[v] < -1:
                    node[v] = u
                    q.append(v)
            else:
                continue
            break
        else:
            break

        u = X + Y + 1
        while node[u] >= 0:
            edge[node[u]].remove(u)
            edge[u].add(node[u])
            u = node[u]


    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7912
x,y = map(int,input().split())
ans = x*y
def compare(s1,s2,s3):
    s = [s1,s2,s3]
    s.sort()
    global ans
    ans = min(ans,abs(s[0]-s[2]))

def divide2(s1,h,w):
    compare(s1,h//2*w,(h-h//2)*w)
    compare(s1,(h//2+1)*w,(h-(h//2+1))*w)
    compare(s1,h*(w//2),h*(w-w//2))
    compare(s1,h*(w//2+1),h*(w-(w//2+1)))


def divide3(h,w):
    divide2((h//3)*w,h-h//3,w)
    divide2((h//3+1)*w,h-(h//3+1),w)
    divide2((w//3)*h,h,w-(w//3))
    divide2((w//3+1)*h,h,w-(w//3+1))

divide3(x,y)
print(ans)

Measured memory_bytes: 38256
using System.Linq;
using static System.Console;

namespace AtCoder.Probrems.Solvers.ABC116
{
    public class _C
    {
        static void Main(string[] args)
        {
            WriteLine(Solve());
        }

        static int N;
        static int[] H;
        public static long Solve()
        {
            N = int.Parse(ReadLine().Split()[0]);
            H = ReadLine().Split().Select(int.Parse).ToArray();
            var depth = H[0];
            var count = 0L;
            for (int i = 1; i < H.Length; i++)
            {
                var h = H[i];
                if (depth == h)
                    continue;
                if (depth < h)
                    depth = h;
                else
                {
                    count += depth - h;
                    depth = h;
                }
            }
            return count + depth;
        }

        private const int MOD = 1000000007;
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 1e9+7;
int N, a[303];
double DP[303][303][303]; // 皿にあるのが1,2,3この確率。

double dfs(int x, int y, int z) {
  if (x == 0 && y == 0 && z == 0) return 0.0;
  if (DP[x][y][z]>0) return DP[x][y][z]; 
  double ret = 0.0;
  if (x>0) ret += dfs(x-1,y,z) *x;
  if (y>0) ret += dfs(x+1,y-1,z) *y;
  if (z>0) ret += dfs(x,y+1,z-1) *z;
  ret += N;
  ret /= (double)(x+y+z);
  DP[x][y][z] = ret;
  return ret; 
}

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

  cin >> N;
  int x=0,y=0,z=0;
  rep(i, N) {
    cin >> a[i];
    if (a[i] == 1) x++;
    if (a[i] == 2) y++;
    if (a[i] == 3) z++;
  }
  cout << fixed << setprecision(10) << dfs(x,y,z) << "\n";
  return 0;
}

Measured memory_bytes: 217472
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n, l;
    cin >> n >> l;
    vint aji(n);
    int tot=0;
    REP(i,n){
        tot += l + i;
    }
    int ans = 1e8 + 7,kind;
    REP(i, n)
    {
        aji[i] = tot - (l + i);
        if (abs(aji[i]-tot) <= ans){
            kind = i;
            ans = abs(aji[i] - tot);
        }
    }
    cout << aji[kind] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef	pair<int, int> pint;
int main() {
  int N; cin>>N;
  vector<pint> data(N);
  REP(i,N) {
    int	a; cin>>a;
    data[i] = make_pair(a, i);
  }
  sort(data.begin(), data.end());
  vector<int> ans(N);
  REP(i,N/2) {
    ans[data[i].second] = data[N/2].first;
  }
  for(int i = N/2; i < N; i++) {
    ans[data[i].second] = data[N/2-1].first;
  }
  REP(i,N) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	int cA = 0;
	int cB = 0;
	int cBoth = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		cA += (s.back() == 'A');
		cB += (s.front() == 'B');
		if (s.back() == 'A' && s.front() == 'B') {
			cBoth++;
			cA--;
			cB--;
		}
		for (int j = 0; j + 1 < (int)s.size(); j++) {
			ans += (s[j] == 'A' && s[j + 1] == 'B');
		} 
	}
	// cerr << ans << endl;
	// cerr << cA << ' ' << cB << ' ' << cBoth << endl;
	if (abs(cA - cB) < cBoth) {
		if (max(cA, cB) > 0) {
			cout << ans + max(cA, cB) + (cBoth - abs(cA - cB)) << '\n';
		} else {
			cout << ans + cBoth - 1 << '\n';
		}
	} else {
		cout << ans + min(cA, cB) + cBoth << '\n';
	}
}



Measured memory_bytes: 3160
#include <algorithm>
#include <functional>
#include <cmath>
#include <iostream>
#include <vector>

std::uint64_t gcd(std::uint64_t a, std::uint64_t b) {
	if (a == 0) return b;
	if (b == 0) return a;
	return gcd(b, a % b);
}


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

	std::vector<std::uint64_t> T;
	T.reserve(N);

	for (int i = 0; i < N; ++i) {
		std::cin >> T[i];
	}

	std::sort(std::begin(T), std::end(T), std::greater<std::uint64_t>());
	std::uint64_t ans = T[0];

	std::cout << std::endl;
	for (int i = 1; i < N; ++i) {
		ans = ans * (T[i] / gcd(T[i], ans));
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

void solve(ll a,ll b){
  ll cnt = 0;
  while(a*2<=b){
    a*=2;
    cnt+=1;
  }
  // cout << b-a << endl;
  cout << cnt+1 << endl;
}

int main(){
  // int test;
  // cin >> test;
  // while(test--){
  //
  //     solve(a,b);
  // }
  ll a,b;
  cin >> a >> b;
  // if(a>b)
  //   swap(a,b);
  // double blah = (b*1.0) / (a*1.0);
  // ll ans = (ll)log2(blah);
  // cout << ans+1 << endl;
  solve(a,b);
}


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

int const N = 1000;
int dp[N + 2][N + 2], n, m;
char g[N + 1][N + 2];

void U() { f(i, 1, n + 1)f(j, 1, m + 1)if (g[i][j] == '.')dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1); }
void L() { f(i, 1, n + 1)f(j, 1, m + 1)if (g[i][j] == '.')dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1); }
void D() { for (int i = n; i > 0; --i)for (int j = m; j > 0; --j)if (g[i][j] == '.')dp[i][j] = min(dp[i][j], dp[i + 1][j] + 1); }
void R() { for (int i = n; i > 0; --i)for (int j = m; j > 0; --j)if (g[i][j] == '.')dp[i][j] = min(dp[i][j], dp[i][j + 1] + 1); }

int main(){
	scanf("%d%d", &n, &m);
	f(i, 1, n + 1)scanf("%s", g[i] + 1);
	f(i, 0, n + 2)f(j, 0, m + 2)dp[i][j] = g[i][j] == '#' ? 0 : 1e9;
	U();
	L();
	D();
	R();
	U();
	L();
	D();
	int an = 0;
	f(i, 1, n + 1)f(j, 1, m + 1)an = max(an, dp[i][j]);
	printf("%d\n", an);
}

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

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

    int n, s, t;
    cin >> n >> s >> t;
    vector<pair<int, int>> path;
    path.emplace_back(0, s);
    cout << "? " << s << ' ' << t << endl;
    int d;
    cin >> d;
    path.emplace_back(d, t);
    for (int i = 1; i <= n; i++) {
        if (i == s || i == t) continue;
        cout << "? " << s << ' ' << i << endl;
        int a;
        cin >> a;
        cout << "? " << i << ' ' << t << endl;
        int b;
        cin >> b;
        if (d == a + b) {
            path.emplace_back(a, i);
        }
    }
    sort(path.begin(), path.end());
    int N = path.size();
    vector<bool> check(N);
    check[0] = true;
    stringstream ans;
    ans << "! " << s;
    int prev = s, prevd = 0;
    while (1) {
        for (int i = 1; i < N; i++) {
            if (check[i] == false) {
                int a = path[i].second;
                cout << "? " << prev << ' ' << a << endl;
                int c;
                cin >> c;
                if (c != path[i].first - prevd) {
                    check[i] = true;
                } else {
                    prev = a;
                    prevd = path[i].first;
                    check[i] = true;
                    ans << ' ' << a;
                    if (a == t) goto finish;
                    break;
                }
            }
        }
    }
    finish:
    cout << ans.str() << endl;
}


Measured memory_bytes: 4648
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	int n,a,b,c;
	int l[8]={0};
	scanf("%d %d %d %d",&n,&a,&b,&c);
	for(int i=0;i<n;i++){scanf("%d",&l[i]);}
//入力終了
	int use[8]={0};
	int minmp=32767;
	int mp;
	for(int i=0;i<pow(4,n);i++){//iの4進数で桁ごとに竹に割り当てる.
		mp=0;
		for(int keta=0;keta<8;keta++){use[keta]=(i/(int)pow(4,keta))%4;}
		//ここまでで竹L0~L8に0~4の使い道番号を振る
		int take[4]={0};//竹a,b,cの合計の長さ,take[0]は使わない竹の合計の長さ
		for(int j=0;j<8;j++){
			if(use[j]!=0 && take[use[j]]!=0){mp+=10;}//竹を繋ぐときのmp消費
			take[use[j]] += l[j];//竹を繋ぐ
		}
		if(take[1]==0 ||take[2]==0 ||take[3]==0){continue;}//条件に合わない時最初から
		mp += (abs(take[1]-a)+abs(take[2]-b)+abs(take[3]-c));//竹の伸縮の時のmp消費
		if(mp<minmp){minmp=mp;}
	}
	printf("%d\n",minmp);
	return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
	char suit;
	int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int left, int mid, int right) {
	int i, j, k;
	int n1 =  mid - left;
	int n2 =  right - mid;
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = SENTINEL;
    R[n2].value = SENTINEL;
    i = j = 0;
    for(k = left; k < right; k++) {
    	if(L[i].value <= R[j].value) {
	    	A[k] = L[i++];
	    } else{
    		A[k] = R[j++];
    	}
    } 		
}

void mergeSort(struct Card A[], int left, int right) {
	int mid;
	if( left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}	
}

int partition(struct Card A[], int p, int r) {
    int i, j;
	struct Card t, x;
	x = A[r];
	i = p - 1;
	for(j = p; j < r ;j++) {
		if(A[j].value <= x.value) {
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;	
    return i+1;
}

void quickSort(struct Card A[], int p, int r) {
	int q;
	if(p < r) {
		q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

int main() {
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
	    A[i].value = B[i].value = v;		
	}
	
	mergeSort(A, 0, n);
	quickSort(B, 0, n-1);
	
	for(i = 0; i < n; i++) {
		if(A[i].suit != B[i] .suit) stable = 0;
	} 
	
	if(stable == 1) printf("Stable\n");
	else printf("Not stable\n");
	for(int i = 0; i < n; i++ ) {
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;	
	
}

Measured memory_bytes: 5012
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    set<char> st;
    REP(i,s.size()) st.insert(s[i]);
    ATYN(st.size() == 2) 

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b=0,i;
for(i=0;i<5;i++){
scanf("%d\n",&a);
if(a<40){
b=b+40;
}
else{
b=a+b;
}
}
printf("%d\n",b/5);
return 0;
}



Measured memory_bytes: 1932
import java.util.Arrays; 
import java.util.Scanner; 
public class Main { public static void main(String[] args) { 
Scanner keyboard = new Scanner(System.in); 

int N = keyboard.nextInt(); 

int sumW = 0;
int[] s1 = new int[N];

for(int i =0; i<N; i++){
sumW += keyboard.nextInt(); 
s1[i] = sumW;
}

int[] z = new int[N-1];

for(int j =0; j<N-1; j++){
z[j] = Math.abs((sumW - s1[j]) - s1[j]);
}

Arrays.sort(z);

		System.out.println(z[0]);
		keyboard.close();
	 	}
 } 


Measured memory_bytes: 23892
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e8;
int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	int Maax = 0;
	map<string, int> mp;
	rep(i, n) {
		cin >> s[i];
		mp[s[i]]++;
		Maax = max(mp[s[i]], Maax);
	}
	vector<string>ss(n);
	int cnt = 0;
	rep(i, n) {
		if (mp[s[i]] == Maax) {
			ss[cnt] = s[i];
			mp[s[i]] = 0;
			cnt++;
		}
	}
	sort(ss.begin(), ss.begin() + cnt);
	rep(i, cnt)
		cout << ss[i] << endl;
}


Measured memory_bytes: 31452
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j,k;
long long dp[100+5][100000+5];
void solve(){
       ll n; cin>>n; 
       ll w; cin>>w;
       ll z=0;
        vector<pair<long long ,long long>> v; 
        for(i=0;i<n;i++){
            ll x,y; cin>>x>>y;
            v.pb(mp(x,y));
        }
        sort(all(v));
       for(i=0;i<n;i++){
        for(j=1;j<=w;j++){
            if(j<v[i].ft) dp[i+1][j]=dp[max(z,i)][j];
            else{
                ll v1=v[i].sd;
                ll w1=v[i].ft;
                dp[i+1][j]=max((v1+dp[max(z,i)][max(z,j-w1)]),dp[i][j]);
            }
        }
       }
       cout<<dp[n][w];
}
 signed main(){
    solve();
    return 0;
  }

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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	int max_pow = INT_MIN;
	int pow = 0;
	if (N == 1) {
		max_pow = 1;   // コーナーケースに注意！
	} else {
		for (int i = 0; i < N; i++) {
			pow = i * i;
			if (pow > N) {
				break;
			}
			if (pow >= max_pow) {
				max_pow = pow;
			}
		}
	}

	cout << max_pow << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

map<int, int> mp;

void addMp(int tmp) {
  auto itr = mp.find(tmp);
  if (itr != mp.end()) mp[tmp]++;
  else mp[tmp] = 1;
}

int main() {
  int n;
  cin >> n;
  rep (i, n) {
    int tmp;
    cin >> tmp;
    addMp(tmp);
    addMp(tmp - 1);
    addMp(tmp + 1);
  }
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    ans = max(ans, itr->second);
  }
  P(ans);

  return 0;
}

Measured memory_bytes: 4736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] nab = str.split(" ");
		int n = Integer.parseInt(nab[0]);
		long a = Long.parseLong(nab[1]);
		long b = Long.parseLong(nab[2]);

		str = input.readLine();
		String[] strx = str.split(" ");
		long[] x = new long[n];
		for(int i=0; i<n; i++){
			x[i] = Long.parseLong(strx[i]);
		}

		long answer = 0;
		for(int i=0; i<n-1; i++){
			if((x[i+1]-x[i])*a > b){
				answer = answer + b;
			}else{
				answer = answer + (x[i+1]-x[i])*a;
			}
		}
		System.out.println(answer);

	}

}


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

using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
int main()
{
    int n;
    cin >> n;
    vector<int> x;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        x.pb(t);
    }
    sort(x.begin(), x.end());
    int ans = 0;
    int c = 2;
    for (int i = 0; i < n - 2; i++)
    {
        for (int k = i + 2; k < n; k++)
        {
            for (int j = i + 1; j < k; j++)
            {
                if ((x[i] != x[j]) && (x[j] != x[k]))
                {
                    if ((x[i] + x[j]) > x[k])
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
    int n;
    ll ans = 0;
    cin >> n;

    map<string, int> mp;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    
    for (auto hoge : mp)
    {
        int a = hoge.second;
        ans += (ll)a * (a - 1) / 2;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <utility>
#include <string>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	vector<pair<int,int>> ps;
	vector<bool> ac(n,false);
	vector<int> wa(n,0);
	int wa_c=0,ac_c=0;
	for(int i=0;i<m;++i){
		string st;
		int p,s;
		cin >> p >> st;
		if(st == "WA")ps.push_back(make_pair(p-1,0));
		else ps.push_back(make_pair(p-1,1));
	}
	for(int i=0;i<m;++i){
		if(ac[ps[i].first]==false && ps[i].second == 0)wa[ps[i].first]++;
		else if(ps[i].second == 1){
			ac[ps[i].first] = true;
		}
	}
	for(int i=0;i<n;++i){
		if(ac[i] == true){
			ac_c++;
			wa_c += wa[i];
		}
	}
	cout << ac_c << " " << wa_c << endl;
}

Measured memory_bytes: 1788
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

b = a.map{|aa| (aa + 1) / 2.0}
# p b
max = 0
sum = b[0..(k-1)].inject(:+)
(k).upto(n-1) do |i|
  # p sum
  max = sum if sum > max
  sum += b[i]
  sum -= b[i-(k)]
end
max = sum if sum > max

p max




Measured memory_bytes: 16516
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int n,tot;
const int N=200010;
int head[N],to[N<<1],nt[N<<1],ans[N],mx[N],fa[N],son[N],sf[N],sub[N];
vector<int>v[N];
void add(int f,int t)
{
	to[++tot]=t;nt[tot]=head[f];head[f]=tot;
}
namespace DSU
{
	int fa[N],siz[N];
	void YYCH(){for(int i=1;i<=n;++i)fa[i]=i,siz[i]=1;}
	int find(int x){return x==fa[x]?fa[x]:fa[x]=find(fa[x]);}
	void he(int x,int y)
	{	
		x=find(x);y=find(y);if(x==y)return;
		fa[x]=y;siz[y]+=siz[x];
	}
}
void dfs1(int x,int fa)
{
	::fa[x]=fa;mx[x]=max(mx[fa],fa);sf[x]=son[mx[x]];
	for(int i=head[x];i;i=nt[i])
		if(to[i]!=fa)son[x]=to[i],dfs1(to[i],x);
}
void dfs2(int x,int fa)
{
	if(fa)ans[x]+=ans[mx[x]]-sub[son[mx[x]]]+1;
	for(int i=head[x];i;i=nt[i])
		if(to[i]!=fa)son[x]=to[i],dfs2(to[i],x);
}
int main()
{
	cin>>n;DSU::YYCH();
	for(int i=1,x,y;i<n;++i)
		scanf("%d%d",&x,&y),add(x,y),add(y,x);
	dfs1(1,0);
	for(int i=2;i<=n;++i)v[mx[i]].push_back(i);
	
	for(int i=1;i<=n;++i)
	{
		for(int j=0,siz=v[i].size();j<siz;++j)
		{
			int x=v[i][j];
			if(x<i)ans[x]=DSU::siz[DSU::find(x)]-1;
			else
			{
				if(x!=sf[x])ans[x]+=DSU::siz[DSU::find(sf[x])];
				for(int k=head[x];k;k=nt[k])
					if(to[k]!=fa[x]&&to[k]<i)
					{
						sub[to[k]]=DSU::siz[DSU::find(to[k])];
						ans[x]+=sub[to[k]];
					}
			}
		}
		for(int j=head[i];j;j=nt[j])
			if(to[j]<i)DSU::he(i,to[j]);
	}
	dfs2(1,0);
	for(int i=2;i<=n;++i)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 26740
n,m=map(int, input().split())
h=list(map(int, input().split()))
root=[list(map(int,input().split()))  for _ in range(m)]

ans=0
lis=[1 for _ in range(n)]

for i in range(len(root)):
    a=root[i][0]
    b=root[i][1]
    if h[a-1] > h[b-1]:
        lis[b-1]=0
    elif h[a-1]< h[b-1]:
        lis[a-1]=0
    else:
        lis[a-1]=0
        lis[b-1]=0

ans=sum(lis)
print(ans)

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

namespace ConsoleApplication37
{
    class Program
    {
        static void Main()
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            for(int c = 0; c < a.Length - b.Length + 1; c++)
            {
                for(int d = 0; d < b.Length; d++)
                {
                    if (a[c + d] != b[d]) break;
                    if (b.Length - 1 == d) Console.WriteLine(c);
                }
            }
        }
    }
}

Measured memory_bytes: 9108
while True:
	H,W=[int(i) for i in input().split(" ")]
	if H==W==0:
		break

	for h in range(H):
		s="#" if h%2==0 else "."
		for w in range(W-1):
			s+="#" if s[-1]=="." else "." 	
		print(s)
	print()

Measured memory_bytes: 6720