akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
        cin >>H >> W;
        if(H == 0 && W == 0){
        break;
    }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout <<'#';
            }
            cout <<endl;
        }
        cout <<endl;
    }
}


Measured memory_bytes: 3084
N,M=map(int,input().split())
D=[]
ans=0; count=0
for i in range(N): 
    A,B=map(int,input().split())
    D.append([A,B])
D.sort()
for i in range(N):
    if count==M: break
    if D[i][1]+count<=M:
        count+=D[i][1]
        ans+=D[i][0]*D[i][1]
    else:
        ans+=D[i][0]*(M-count)
        count=M
print(ans)

Measured memory_bytes: 21656
from heapq import heappush, heappop

def dijkstra_heap(s):
    """頂点sから各頂点への最短距離"""
    d = [float("inf") for _ in range(N)]
    used = [True for _ in range(N)]  # True: 未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heappush(edgelist, e)
    while len(edgelist):
        min_edge = heappop(edgelist)
        # まだ使われていない頂点の中から最小距離のものを探す
        if not used[min_edge[1]]:
            continue
        v = min_edge[1]
        d[v] = min_edge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heappush(edgelist, [e[0]+d[v], e[1]])
    return d

N = int(input())

edge = [[] for _ in range(N)]  # edge[i]: i から出る道の[重み、行き先]の配列

for _ in range(N-1):
    x, y, z = map(int, input().split())
    edge[x-1].append([z, y-1])
    edge[y-1].append([z, x-1])

Q, K = map(int, input().split())
z = dijkstra_heap(K-1)

for _ in range(Q):
    x, y = map(int, input().split())
    print(z[x-1] + z[y-1])


Measured memory_bytes: 58304
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var ret = k * (int)Math.Pow(k - 1, n - 1);
        Console.WriteLine(ret);
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	int a;
	scanf("%d",&a);
	printf("%d",a*(1+a*(1+a)));
}

Measured memory_bytes: 1728
S = input()[::-1]
P = [0]*(len(S)+1)
a = 0
for i,j in enumerate((S)):
    a = (a+int(j)*pow(10,i,2019))%2019
    P[i] = a

dp = [0]*2019
for i in P:
    dp[i%2019] += 1
print(sum([i*(i-1)//2 for i in dp]))

Measured memory_bytes: 16252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int n;
auto memo = make_vec<double>(330, 330, 330);
double dp(int i, int j, int k) {
    if (memo[i][j][k] != -1) return memo[i][j][k];
    if (i == 0 && j == 0 && k == 0) return memo[i][j][k] = 0;
    double ret = 1.0;
    if (i > 0) ret += ((double)i / double(n)) * (dp(i - 1, j, k));
    if (j > 0) ret += ((double)j / double(n)) * (dp(i + 1, j - 1, k));
    if (k > 0) ret += ((double)k / double(n)) * (dp(i, j + 1, k - 1));
    ret /= (1 - ((double)(n - i - j - k) / (double)(n)));
    return memo[i][j][k] = ret;
}
int main() {
    cin >> n;
    int c1 = 0, c2 = 0, c3 = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a == 1) c1++;
        if (a == 2) c2++;
        if (a == 3) c3++;
    }
    rep(i, 330) rep(j, 330) rep(k, 330) memo[i][j][k] = -1;
    cout << fixed << setprecision(20) << dp(c1, c2, c3) << endl;
}

Measured memory_bytes: 286208
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
int M = 1e9 + 7;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s , t;
  cin >> s >> t;
  bool flag = 0;
  for (int i = 0; i < s.length(); ++i)
  {
    if (s[i] != t[i])
    {
      flag = 1 ;
      break;
    }
  }
  if (flag)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans,a,i;
  cin>>n;
  ans=0;
  vector<int> zyunban(n);
  vector<int> mannzokudo(n);
  vector<int> tuika(n-1);
  for(i=0; i<n; i++){
    cin>>zyunban.at(i);
  }
  for(i=0; i<n; i++){
    cin>>a;
    ans=ans+a;
  }
  for(i=0; i<n-1; i++){
    cin>>tuika.at(i);
  }
  for(i=0; i<n-1; i++){
    if(zyunban.at(i)+1==zyunban.at(i+1)){
      a=zyunban.at(i)-1;
      ans=ans+tuika.at(a);
    }
  }
  cout<<ans;
}

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

int main(){
 while(1){
 int H,W;
 cin >>H>>W;
 if(H ==0 && W==0)break;
 for(int i=0;i<H;i++){
 for(int i=0;i<W;i++){
 
 cout<<"#";
 }
cout<<endl;
}
cout<<endl;
}

}


Measured memory_bytes: 3068
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,m,d,t;
	bool ans = true;
	cin >> n;
	map<int, int>md, mt;
	rep(i, n) {
		cin >> d;
		md[d]++;
	}
	cin >> m;
	rep(i, m) {
		cin >> t;
		mt[t]++;
	}
	for (auto q : mt) {
		if (q.second > md[q.first])ans = false;
	}
	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}



Measured memory_bytes: 22336
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();
		char[] s=sc.next().toCharArray();
		s[k-1]+='a'-'A';
		System.out.println(s);	
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct mod_fac{
    private:
        vector<ll> f,i_f;
        int n;ll MOD;
    public:
        void init(int n,ll m){
            MOD=m;
            f.resize(n+1,0);
            i_f.resize(n+1,0);
            f[0]=1;
            rep(i,n){
                f[i+1]=f[i]*(i+1)%MOD;
            }
            i_f[n]=power(f[n],MOD-2);
            per(i,n){
                i_f[i]=(i_f[i+1]*(i+1))%MOD;
            }
        }
        ll power(ll a ,ll x){
            if (x==0) return 1;
            if (x==1) return a%MOD;
            if (x==2) return (a*a)%MOD;
            if (x%2==1) return (a*power(power(a,(x-1)/2),2))%MOD;
            return (power(power(a,x/2),2))%MOD;
        }
        ll fac(int x){
            return f[x];
        }
        ll invfac(int x){
            return i_f[x];
        }
        ll comb(int m,int k){
            if (m<0 or k<0) return 0;
            if (m<k) return 0;
            return (((f[m]*i_f[k])%MOD)*i_f[m-k])%MOD;
        }
};

int n,k;
vector<int> ans;

void solve(){
    cin >> n >> k;
    mod_fac m;m.init(10000,mod);
    Rep(i,1,k+1){
        cout << m.comb(k-1,i-1)*m.comb(n-k+1,i)%mod << endl;
    }
}

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

Measured memory_bytes: 384
import re

# +C
xAG = re.compile('[ACGT]AG')
AxG = re.compile('A[ACGT]G')
xGA = re.compile('[ACGT]GA')
AGx = re.compile('AG[ACGT]')

# +G
xAC = re.compile('[ACGT]AC')

def func(N):
    d = {a+b+c:1 for a in 'ACGT' for b in 'ACGT' for c in 'ACGT' if a+b+c not in ('AGC','ACG','GAC')}
    for i in range(N-3):
        e = {a+b+c:0 for a in 'ACGT' for b in 'ACGT' for c in 'ACGT' if a+b+c not in ('AGC','ACG','GAC')}
        for k,v in d.items():
            if xAG.match(k) or AxG.match(k) or xGA.match(k) or AGx.match(k):
                n = 'AGT'
            elif xAC.match(k):
                n = 'ACT'
            else:
                n = 'ACGT'
                
            for i in n:
                e[k[1:]+i] += v
                    
        d = e
    print(sum(d.values())%(10**9+7))
    
    
func(N=int(input()))

Measured memory_bytes: 3188
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto abck = readln.split.to!(long[]);
    auto A = abck[0];
    auto B = abck[1];
    auto K = abck[3];

    writeln(K&1 ? B - A : A - B);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define mod1 1000000007
#define mod2 998244353
#define debug(x) cout<<#x<<" : "<<x<<endl

int main()
{
	optimize

	string s1,s2;

	cin>>s1;
	cin>>s2;

	bool ch = true;
	forab(i,0,s1.size())
	{
		if(s1[i] != s2[i])
		{
			cout<<"No"<<endl;
			ch = false;
			break;
		}
	}
	if(ch)
		cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
const MOD: usize = 1e9 as usize + 7;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let x: usize = sc.read();
    let mut s: Vec<usize> = sc.vec(n);
    s.sort();
    s.reverse();

    let mut dp = vec![vec![0; x + 1]; n + 1];
    dp[0][x] = 1;
    for i in 0..n {
        for j in 0..(x + 1) {
            // unused
            dp[i + 1][j] += dp[i][j] * (n - 1 - i);
            dp[i + 1][j] %= MOD;

            // used
            dp[i + 1][j % s[i]] += dp[i][j];
            dp[i + 1][j % s[i]] %= MOD;
            // if j < s[i] {
            //     let mut k = 0;
            //     while j + k * s[i] <= x {
            //         dp[i + 1][j] += dp[i][j + k * s[i]];
            //         dp[i + 1][j] %= MOD;
            //         k += 1;
            //     }
            // }
        }
    }

    let mut ans = 0;
    for i in 1..s[n - 1] {
        ans += dp[n][i] * i;
        ans %= MOD;
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 209148
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}
template<typename T>
void debug(vector<T> V){
    for(auto x:V){
        cout<<x<<" ";
    }
    cout<<endl;
}
void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout<<fixed<<setprecision(8);
    go();
    return 0;
}
/*************************************/
const int MAXN=105;
int G[MAXN][MAXN];
void go(){
    int n,k;
    R(n,k);
    int cnt=0;
    rep(i,1,n){
        rep(j,i+1,n){
            cnt++;
            G[i][j]=1;
        }
    }
    if(k>(n-1)*(n-2)/2){
        W(-1);
        return;
    }
    rep(i,2,n){
        rep(j,i+1,n){
            if(k){
                G[i][j]=0;
                cnt--;
                k--;
            }
        }
    }
    W(cnt);
    rep(i,1,n){
        rep(j,i+1,n){
            if(G[i][j]){
                W(i,j);
            }
        }
    }
}


Measured memory_bytes: 384
//AND BAND KA TOLA JO MERA CODE DEKHRA WO BHEN KA ....
//------------------------------------------Template------------------------------------------------
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define lp(i,a,b) for(ll i=a;i<b;i++)
#define rlp(i,a,b) for(ll i=b;i>=a;i--)
#define TEZI_BOLTEY ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back 
#define mp make_pair 
#define endl "\n"
ll nCr(ll n, ll k) {double res = 1;lp(i,1,k+1){res = res * (n - k + i) / i;}return (int)(res + 0.01);}
//---------------------------------------------------------------------------------------------------
//---------------------------------<<< DRAGON SIN MELIODAS >>>---------------------------------------
//---------------------------------------------------------------------------------------------------
int main()
{
	TEZI_BOLTEY
	ll t;
	cin >> t;
	cout << t+pow(t,2)+pow(t,3) << endl;
}


Measured memory_bytes: 4176
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String s = sc.next();
	    if(s.equals("Sunny")) {
	        System.out.println("Cloudy");
	    }
	    if(s.equals("Cloudy")) {
	        System.out.println("Rainy");
	    }
	    if(s.equals("Rainy")) {
	        System.out.println("Sunny");
	    }
	    
	    
	}
}

Measured memory_bytes: 22608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C; cin >> A >>B>>C;
    cout << max(0,C-(A-B)) << endl;

}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
// #define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin >> a >> b >> c;

    if(a == b && a != c) cout << "Yes" << endl;
    else if(b == c && a != b) cout << "Yes" << endl;
    else if(a == c && b != c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
 
P = [0] * (n + 1)
P[0] = 1
for i in range(1, n + 1):
    P[i] = P[i - 1] * 2 + 1

A = [0] * (n + 1)
A[0] = 1
for i in range(1, n + 1):
    A[i] = A[i - 1] * 2 + 3

#print(P)
#print(A)
 
def dfs(n, x):
    if n == 0:
        return 1
    if x == 1:
        return 0
    elif 1 < x <= 1 + A[n - 1]:
        return dfs(n - 1, x - 1)
    elif x == 1 + A[n - 1] + 1:
        return P[n - 1] + 1
    elif 1 + A[n - 1] + 1 < x < 1 + A[n - 1] + 1 + A[n - 1] + 1:
        return P[n - 1] + 1 + dfs(n - 1, x - 1 - A[n - 1] - 1)
    elif x >= 1 + A[n - 1] + 1 + A[n - 1] + 1:
        return P[n - 1] + 1 + P[n - 1]
    
print(dfs(n, x))    

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

int main()
{
    long n, m;
    cin >> n >> m;
    vector<long> h(n+1);
    for(long i = 1; i <= n; i++)
        cin >> h[i];
    vector<long> adjc(n+1, 0);
    long u, v;

    set<pair<long, long>> roads;

    vector<long> lc(n+1, 0);
    for (long i = 0; i < m; i++)
    {
        cin >> u >> v;
        if (u > v)
            swap(u, v);
        roads.insert({u, v});
    }

    for (auto r: roads)
    {
        u = r.first;
        v = r.second;
        if (h[u] < h[v])
            lc[v] ++;
        else if (h[v] < h[u])
            lc[u] ++;
        adjc[u] ++;
        adjc[v] ++;
    }
    long fans = 0;
    for (long i = 1; i<= n; i++)
    {
        if (lc[i] == adjc[i]) fans ++;
    }
//    for (long i = 1; i<=n; i++)
//        cout << lc[i] << " ";
//    cout << endl;
    cout << fans;
    return 0;
}

Measured memory_bytes: 11972
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>
#include <complex>
#include <numeric>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define gcd(x,y) __builtin_gcd(x,y)
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek = 998244353;

int main() {
	mipletsplay;
	int n;
	cin >> n;
	int l;
	cin >> l;
	int sum = 0;
	bool ok = false;
	int a = INF;
	for (int i = 0; i < n; i++){
		sum += (l + i);
		a = min(abs(l + i),a);
}
if (l<0)
cout<<sum+a;
else
cout<<sum-a;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

string S3[] = {
	"abb",
	"a.c",
	"ddc"
};
string S4[] = {
	"abcc",
	"abdd",
	"eefg",
	"hhfg"
};
string S5[] = {
	"aabbc",
	"d..ec",
	"d..ef",
	"ghh.f",
	"giijj"
};

int main() {
	int N; cin >> N;
	if (N % 3 == 0) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				cout << S3[i % 3][j % 3];
			}
			cout << endl;
		}
		return 0;
	}
	else if (N == 7) {
		cout << "aab..cc" << endl;
		cout << "..bdde." << endl;
		cout << "f...ge." << endl;
		cout << "f...ghh" << endl;
		cout << ".iijj.l" << endl;
		cout << "m..n..l" << endl;
		cout << "moon..." << endl;
		return 0;
	}
	else if (N == 11) {
		cout << "abb.......a" << endl;
		cout << "a.c.......a" << endl;
		cout << "ddc......a." << endl;
		cout << "...abb...a." << endl;
		cout << "...a.c..a.." << endl;
		cout << "...ddc..a.." << endl;
		cout << "......wkbb." << endl;
		cout << "......wk.aa" << endl;
		cout << ".....hhpp.t" << endl;
		cout << "a..cc.....t" << endl;
		cout << "abb...rr..." << endl;
		return 0;
	}
	else {
		int n = 0, m = 0;
		for (int i = 0; i < N; i++) {
			if ((N - 4 * i) % 5 == 0) {
				n = i;
				m = (N - 4 * n) / 5;
				break;
			}
		}

		if (n == 0 && m == 0) { cout << -1 << endl; return 0; }
		if (m < 0) { cout << -1 << endl; return 0; }

		string* S = new string[N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				S[i].push_back('.');
			}
		}

		for (int i = 0; i < n; i++) {
			for (int p = 0; p < 4; p++) {
				for (int q = 0; q < 4; q++) {
					S[i * 4 + p][i * 4 + q] = S4[p][q];
				}
			}
		}
		for (int i = 0; i < m; i++) {
			for (int p = 0; p < 5; p++) {
				for (int q = 0; q < 5; q++) {
					S[n * 4 + i * 5 + p][n * 4 + i * 5 + q] = S5[p][q];
				}
			}
		}
		for (int i = 0; i < N; i++) {
			cout << S[i] << endl;
		}
		return 0;
	}

	cout << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 2304
#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

const int MAX = 3100000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}
ll sum[MAX];
// ax + by = gcd(a, b) となるような (x, y) を求める
// a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰
    y -= a / b * x;
    return d;
}


// 負の数に対応した mod
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}


// 逆元計算 (a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // x % m だが、x が負かもしれないので
}
int main() {
    COMinit();
    ll n, m;
    cin >> n >> m;

    ll ans = 0;

    sum[0] = 1;
    ll now = 1;
    srep(i,1,MAX){
        now = now * (n-2+i) % MOD * modinv(i,MOD) % MOD;
        sum[i] = sum[i-1] + now;
        sum[i] %= MOD;
    }

    int min_nm = min(n,m);

    rep(i,min_nm+1){ // 奇数の数
        if((3*m-i)%2==1) continue;
        ll num = (3*m-i)/2;
        ll tmp = COM(num+n-1,num) * COM(n,i) % MOD;
        ll tmp1 = 0;
        if(num-(m+1) >= 0) tmp1 = sum[num-(m+1)];
        tmp1 = tmp1 * COM(n-1,i) % MOD * n % MOD;
        ll tmp2 = 0;
        if(num-m >= 0) tmp2 = sum[num-m];
        tmp2 = tmp2 * COM(n-1,i-1) % MOD * n % MOD;
        tmp = tmp + MOD - tmp1 + MOD - tmp2;
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 100444
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    double a,b,x; cin >> a >> b >> x;
    double y;
    if(x <= a*a*b/2) y = 2 * x / (b * a);
    else{
        double z = a * a * b - x;
        y = 2 * z / (a * a);
    }

    if(x <= a*a*b/2)cout << fixed << setprecision(10) << atan(b / y) * 180.0 / 3.14159265358979<< endl;
    else cout << fixed << setprecision(10) << 90 - atan(a / y) * 180.0 / 3.14159265358979 << endl;
}

Measured memory_bytes: 4020
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=1e5+5,maxm=4e5+5;
const ll inf=1e18;
inline int fa(int u){ return u/2; }
inline int ls(int u){ return u*2; }
inline int rs(int u){ return u*2+1; }
struct heap{
	int hea[maxn],pos[maxn],siz;
	ll *dis;
	heap(ll a[],int n){
		dis=a; siz=n;
		int i;
		for (i=1;i<=n;i++){
			dis[i]=inf; hea[i]=i; pos[i]=i;
		}
	}
	void hswap(int u,int v){
		swap(hea[u],hea[v]);
		pos[hea[u]]=u; pos[hea[v]]=v;
	}
	void update(int u){
		if (u==1) return;
		if (dis[hea[fa(u)]]<=dis[hea[u]]) return;
		hswap(u,fa(u));
		update(fa(u));
	}
	void pushdown(int u){
		int v=u;
		if (ls(u)<=siz&&dis[hea[ls(u)]]<dis[hea[v]]) v=ls(u);
		if (rs(u)<=siz&&dis[hea[rs(u)]]<dis[hea[v]]) v=rs(u);
		if (u==v) return;
		hswap(u,v);
		pushdown(v);
	}
	void change(int u,ll val){
		dis[u]=val;
		update(pos[u]);
		pushdown(pos[u]);
	}
	int pop(){
		hswap(1,siz);
		siz--;
		pushdown(1);
		return hea[siz+1];
	}
};
struct gragh{
	int head[maxn],next[maxm],to[maxm],tot;
	ll wei[maxm],cost[maxn];
	gragh(){
		memset(head,-1,sizeof(head));
		tot=0;
	}
	void clear(){
		memset(head,-1,sizeof(head));
		tot=0;
	}
	void add(int u,int v,ll w,ll c){
		next[tot]=head[u];
		head[u]=tot;
		to[tot]=v;
		wei[tot]=w;
		cost[tot]=c;
		tot++;
	}
	void dijkstra(ll dis[],ll val[],int st,int n){
		heap hp(dis,n);
		hp.change(st,0);
		int i,u,v,ed;
		for (i=1;i<=n;i++) val[i]=inf;
		val[st]=0;
		while (hp.siz){
			u=hp.pop();
			for (ed=head[u];ed!=-1;ed=next[ed])
				if (dis[v=to[ed]]>dis[u]+wei[ed])
					hp.change(v,dis[u]+wei[ed]);
		}
		for (u=1;u<=n;u++) for (ed=head[u];ed!=-1;ed=next[ed])
			if (dis[v=to[ed]]==dis[u]+wei[ed])
			val[v]=min(val[v],cost[ed]);
	}
};
gragh g;
ll dis[maxn],val[maxn];
int main(){
	int n,m,i,u,v;
	ll w,c,ans;
	while (scanf("%d%d",&n,&m)&&(n||m)){
		g.clear();
		for (i=0;i<m;i++){
			scanf("%d%d%lld%lld",&u,&v,&w,&c);
			g.add(u,v,w,c);
			g.add(v,u,w,c);
		}
		g.dijkstra(dis,val,1,n);
		ans=0;
		for (i=1;i<=n;i++) ans+=val[i];
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 4780
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
int main (){
    cin >> N;
    int sum = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        sum += a;
    }
    cout << sum - N << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int n,arr[100000000];
int main()
{
    int flag;
    flag=1;
    long long int i;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&arr[i]);
    }
    sort(arr,arr+n);
    for(i=0;i<n;i++)
    {
        if(arr[i]==arr[i+1])
        {
            flag=0;
            printf("NO");
            break;
        }
        //scanf("%lld",&arr[i]);
    }
    if(flag==1)
    {
        printf("YES");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MAXQ=100000;

int nq,n;
int q[MAXQ];

int dc[MAXN+1];
ll cnst[MAXN+1];

void adddec(int l,int r) {
	if(l>r) return;
	//printf("addec(%d,%d)\n",l,r);
	++dc[l]; --dc[r+1];
	cnst[r+1]+=r-l+1;
}
void addconst(int l,int r,ll val) {
	if(l>r) return;
	//printf("addconst(%d,%d,%lld)\n",l,r,val);
	cnst[l]+=val; cnst[r+1]-=val;
}

void run() {
	scanf("%d%d",&nq,&n);
	REP(i,nq) scanf("%d",&q[i]),--q[i];
	memset(dc,0,sizeof(dc));
	memset(cnst,0,sizeof(cnst));

	ll sum=0;
	REP(i,nq-1) {
		int a=q[i],b=q[i+1];
		if(a==b) continue;
		if(a<b) {
			sum+=b-a;
			adddec(a+1,b);
		} else {
			sum+=b-a+n;
			adddec(a+1,n-1);
			adddec(0,b);
			addconst(0,b,-(n-a-1));
		}
	}
	//printf("sum=%lld\n",sum);

	ll ret=LLONG_MAX;
	ll cur=sum; int curdec=0;
	REP(i,n) {
		cur+=cnst[i]-curdec; curdec+=dc[i];
		//printf("%d: %lld\n",i,cur);
		if(cur<ret) ret=cur;
	}
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

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)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int n, int k, int m) {
    VI v(n);
    m--;
    iota(ALL(v), 0);
    int now = m;
    while (v.size() != 1) {
        //cout << *(v.begin() + now) + 1 << endl;
        v.erase(v.begin() + now);
        now = (now + k - 1) % (int)v.size();
    }
    cout << v[0] + 1 << endl;
    return;
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m >> p, n) {
        solve(n, m, p);
        //return 0;
    }
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  long long cnt[5]={};
  long long ans=0;
  char jd[5]={'M','A','R','C','H'};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    for(int j=0;j<5;j++){
      if(s[0]==jd[j]){
     	cnt[j]++;
      }
    }
  }
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(i==j)continue;
      for(int k=0;k<5;k++){
        if(j==k||i==k) continue;
        ans+=cnt[i]*cnt[j]*cnt[k];
      }
    }
  }
  cout<<ans/6<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
    Scanner scan = new Scanner(System.in);
    
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    if (a<b && b <c)
        System.out.println("Yes");
    else
        System.out.println("No");
    }
}

Measured memory_bytes: 26096
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
c = 0
for i in G[0]:
    if n - 1 in G[i]:
        c = 1
        break
print("POSSIBLE" if c == 1 else "IMPOSSIBLE")

Measured memory_bytes: 38320
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<cstring>
#include<utility>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<deque>
#include<cctype>
using namespace std;
int com(int a,int b)
{
	return a>b;
}
int main() 
{
	int n;
	scanf("%d",&n);
	int dis[n-1];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&dis[i]);
	 } 
	sort(dis,dis+n);
	int min=dis[0];
	sort(dis,dis+n,com);
	int max=dis[0];
	cout<<max-min;
	return 0; 
}
    

Measured memory_bytes: 256
t = int(input())

for i in range(t):
    n,a,b,c,d = map(int, input().split())
    dp = dict()
    dp[0] = 0
    def solve(now):
        if now in dp:
            return dp[now]
        if now == 1:
            dp[now] = d
            return d
        res = d*now
        if now%2 == 0:
            res = min(res,solve(now//2)+a)
        else:
            res = min(res,min(solve((now+1)//2),solve((now-1)//2))+a+d)
        if now%3 == 0:
            res = min(res,solve(now//3)+b)
        else:
            if now//3:
                res = min(res,min(solve(now//3)+d*(now%3),solve(now//3+1)+d*(3-now%3))+b)
            else:
                res = min(res,d*(now%3),d*(4-now%3)+b)
        if now%5 == 0:
            res = min(res,solve(now//5)+c)
        else:
            if now//5:
                res = min(res,min(solve(now//5)+d*(now%5),solve(now//5+1)+d*(5-now%5))+c)
            else:
                res = min(res, d*(now%5),d*(6-now%5)+c)
        dp[now] = res
        return res
    print(solve(n))


Measured memory_bytes: 94584
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

//////LinearSearch////////

int LinearSearch (int a[], int n, int key){
    int i = 0;
    a[n] = key;
    while(a[i]!=key) i++;
    return i != n;
}

int main (){
    int n;
    cin >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
    }
    int q;
    cin >> q;
    int t[q];
    REP(i,q){ 
        cin >> t[i];
    }

    int c = 0;
    REP(i,q){
        int li = LinearSearch(a, n, t[i]);
        if(li==1) c++;
    }
    cout << c << endl;
}


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

vector<int> input(int N) {
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    return vec;
}

void Main() {
    int n,y,k;
    cin >>n>>y;
    int xmax = y / 10000;
    int ymax = y / 5000;
    int ans=0;
    for (int i = 0; i < xmax+1; i++)
    {
        for (int j = 0; j < ymax+1; j++)
        {
            k = n - i - j;
            if (k < 0) {
                continue;
            }
            if (i * 10000 + j * 5000 + k * 1000 == y) {
                ans+=1;
                cout << i << ' ' << j << ' ' << k << endl;
                break;
            }
        }
        if (ans > 0) {
            break;
        }
    }
    if (ans==0) {
        cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    }
    

}


int main() {
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000
#define MOD 1000000007

int main(){
  int M,D;
  cin>>M>>D;
  int ans=0;
  for(int i=1;i<=M;i++){
    for(int j=1;j<=D;j++){
      if((j%10)*(j/10)==i&&j%10>1&&(j/10)>1){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int a,b,x;
    cin >> x>>a >> b;
    cout << (x-a)%b << endl;
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


ll S(ll x) {
    ll res = 0;
    while (x) {
	res += (x%10);
	x /= 10;
    }
    return res;
}


bool snuke(ll n) {

    for (ll i=n+1; i<=n*10; i++) {
	if (n*S(i) > i*S(n)) return false;
    }
    return true;
}

ll k;

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

    cin>>k;

    // for (ll i=1; i<=100000; i++) {
    // 	if (snuke(i)) watch(i);
    // }

    ll add = 1;

    cout<<1<<endl;
    ll cur=1;
    for (int it=2; it<=k; it++) {
	ll nxt=cur+add;
	ll nxt2 = nxt+add;
	if (nxt*S(nxt2) > nxt2*S(nxt)) {
	    add *= 10ll;
	    nxt = cur + add;
	}
	cur = nxt;
	cout<<cur<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <functional>
#include <set>
#include <iomanip>
typedef  long long ll;
using namespace std;

int main(void) {
	ll d, n;
	cin >> d >> n;

	ll ans = pow(100, d) * n ;
	if (n == 100)
	{
		if (d == 0)
		{
			ans = 101;
		}
		else if (d == 1)
		{
			ans = 10100;
		}
		else
		{
			ans = 1010000;
		}
	}


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i;
  int s = 0;
  scanf("%d", &i);
  
  s += (i/500)*1000;
  i -= (i/500)*500;
  s += (i/5)*5;
  i -= (i/5)*5;
  printf("%d", s);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <utility>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N, 0);
  for (int i=0; i<N; i++) std::cin >> A[i];
  
  int cnt = 0;
  for (int i=1; i<N; i++) {
    int j = i;
    while(A[j] < A[j-1]) {
      std::swap(A[j], A[j-1]);
      cnt++;
      j--;
    }
  }
  
  for (int i=0; i<N-1; i++) std::cout << A[i] << ' ';
  std::cout << A[N-1] << std::endl;
  std::cout << cnt << std::endl;
  
  return 0;
}


Measured memory_bytes: 3108
def f(flg, an):
    accum = 0
    ret = 0
    for i, ai in enumerate(an):
        accum += ai
        if i % 2:
            if flg and 0 <= accum:
                ret += accum + 1
                accum = -1
            elif not flg and accum <= 0:
                ret += -accum + 1
                accum = 1
        else:
            if flg and accum <= 0:
                ret += -accum + 1
                accum = 1
            elif not flg and 0 <= accum:
                ret += accum + 1
                accum = -1

    return ret


def main():
    n, *an = map(int, open(0).read().split())
    print(min(f(0, an), f(1, an)))
    return


main()


Measured memory_bytes: 14084
N = int(input())
a = map(int, input().split())

result_num_list = [0] * (10 ** 5 + 5)
for i in a:
    result_num_list[i-1] += 1
    result_num_list[i] += 1
    result_num_list[i+1] += 1

print(max(result_num_list))

Measured memory_bytes: 17224
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    DRI(N);
    int v=0;
    REP(i,N){
        DRI(x);
        v^=x;
    }
    puts(v%2==0?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    string s; cin >> s;
    int ans = 0;
    for(int i = 1; i < s.size(); i++){    
        if (s[i] == s[i-1]){
            ans++;
            if (s[i] == '1'){
                s[i] = '0';
            } else {
                s[i] = '1';
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int c[3][3];
  rep(i, 3) rep(j, 3) cin >> c[i][j];
  rep(i, 3) {
    if (c[0][i]-c[0][(i+1)%3] != c[1][i]-c[1][(i+1)%3] || c[1][i]-c[1][(i+1)%3] != c[2][i]-c[2][(i+1)%3]) {
      cout << "No" << endl;
      return 0;
    }
  }
  rep(i, 3) {
    if (c[i][0]-c[(i+1)%3][0] != c[i][1]-c[(i+1)%3][1] || c[i][1]-c[(i+1)%3][1] != c[i][2]-c[(i+1)%3][2]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

int main()
{
  int n, h, w;
  cin >> n >> h >> w;
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    int a, b;
    cin >> a >> b;
    if (h <= a && w <= b)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
	int loop;
	cin >> loop;
	bool isRight[loop];
	for (int i = 0; i < loop; i++) {
		int num[3];
		int tmp;
		cin >> num[0] >> num[1] >> num[2];
		if (num[0] < num[1]) {
			if (num[1] < num[2]) {
				tmp = num[0];
				num[0] = num[2];
				num[2] = tmp; 
			} else {
				tmp = num[0];
				num[0] = num[1];
				num[1] = tmp; 
			}
		} else if (num[0] < num[2]) {
				tmp = num[0];
				num[0] = num[2];
				num[2] = tmp; 
		}

		if (num[0] * num[0] == num[1] * num[1] + num[2] * num[2]) {
			isRight[i] = true;
		} else {
			isRight[i] = false;
		}
	}
	for (int i = 0; i < loop; i++) {
		cout << (isRight[i] ? "YES" : "NO") << endl;
	}
}

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

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  if (x < 0 || y < 0 || w < (x + r) || h < (y + r)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
k,x = gets.split.map(&:to_i)

result = Array.new

max = 1000000
min = -1000000

if max >= x+k
  k.times do |i|
    result << x + i
  end
end

if min <= x-k
  k.times do |i|
    result << x - i
  end
end

result.uniq.sort.each_with_index do |a,i|
  print a
  if result.uniq.length - 1 != i
    print " "
  end
end


Measured memory_bytes: 2168
c = {}

for char in ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']:
    c[char] = 0


while True:
    try:
        s = input()
        if s == '':
            break
        
        for i in range(len(s)):
            char = s[i : i + 1]
            
            if char.isalpha():
                c[char.lower()] += 1
        
    except EOFError:
        break

for k, v in c.items():
    print(f'{k} : {v}')


Measured memory_bytes: 5576