akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

#ifdef OJ
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#else
#define debug(x)
#define debugv(x)
#endif

#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define sz(x) ((int)x.size())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return ;}while(0)

const int MOD = 1e9+7;
const int MAXN = 2e6+3;
const int INF = 1e9;

void solve() {
    int n; cin >> n;
    int r = n%1000;
    if(r) r = 1000-r;
    cout << r << '\n';
} 

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int ntest = 1;
    //cin >> ntest;
    fori(test, ntest) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3640
n,k=map(int, input().split())
h=list(map(int,input().split()))
dp=[0]*(n)
if k+1<=n:
  max=k+1
else:
  max=n
  
for i in range(1,max):
  dp[i]=abs(h[0]-h[i])
 
for i in range(k,n):
  li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ]
  dp[i]=min(li)
  
print(dp[-1])

Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define size(v) v.size()

const int N=100005;
const int MOD=1e9+7;

 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define printclock cerr<<"Time : "<<1000*(int)clock()/(int)CLOCKS_PER_SEC<<"ms\n"
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/





int n;
cin>>n;

int cnt[25];
cnt[0]=1;
for(int i=1;i<=13;i++)
{
	cnt[i]=cnt[i-1]*26;
}

int x=1;
while(n>cnt[x])
{
	n=n-cnt[x];
	x++;
}
n--;
vector<char> v;
for(int i=0;i<x;i++)
{
	v.pb('a'+n%26);
	n=n/26;
}
reverse(all(v));
for(auto it:v)
cout<<it;



cout<<endl;
printclock;
}




Measured memory_bytes: 3652
O = input()
E = input()

len_pass = len(O) + len(E)
for num in range(1, len_pass + 1):
  if (num % 2 == 1):
    odd_index = num // 2
    print(O[odd_index], end="")
  elif (num % 2 == 0):
    even_index = (num // 2) - 1
    print(E[odd_index], end="")
print("")


Measured memory_bytes: 3060
def main():
    s = input()
    n = len(s)
    min_diff = 1000

    for i in range(n - 2):
        diff = abs(int(s[i: i+3]) - 753)
        if diff < min_diff:
            min_diff = diff

    print(min_diff)


if __name__ == "__main__":
    main()


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

int main(void){
    int n;
    cin >> n;
    
    int input;
    int max, min;
    cin >> input;
    max = input;
    min = input;
    
    int i;
    for(i = 2; i <= n; i++){
        cin >> input;
        if(input > max){
            max = input;
        }
        if(input < min){
            min = input;
        }
    }
    
    cout << max - min << endl;
    
    return 0;
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

int Maze[100][100];
int Wall[100][100][4];
int h, w;

int main(void){
    while(true)
    {

        cin >> w >> h;
        if(!(h || w)) break;

        // 初期化
        for(int i = 0; i < h; ++i) {
            for(int j = 0; j < w; ++j) {
                Maze[i][j] = -1;
                for(int k = 0; k < 4; ++k) {
                    Wall[i][j][k] = 0;
                }
            }
        }

        for(int i = 0; i < 2*h-1; ++i) {
            if(i%2== 0) {
                for(int j = 0; j < w-1; ++j) {
                    int k;
                    cin >> k;
                    // 縦でi/2番目のブロックの横の壁
                    Wall[i/2][j][1] = Wall[i/2][j+1][3] = k;
                }
            } else {
                for(int j = 0; j < w; ++j) {
                    int k;
                    cin >> k;
                    // 縦でi/2番目のブロックの下の壁
                    Wall[i/2][j][2] = Wall[i/2+1][j][0]= k;
                }
            }
        }

        queue<pair<int,int>> tsk;
        tsk.push(make_pair(0,0));
        //long long max_queue = 0;
        while(!tsk.empty())
        {
            //max_queue = max(max_queue, (long long)tsk.size());
            auto p = tsk.front();
            int x = p.first/w, y = p.first%w;
            tsk.pop();
            // ↓これを加えると、MLEを回避した。
            //if(Maze[x][y] != -1) continue;
            // ↑これを加えると、MLEを回避した。
            for(int i = 0; i < 4; ++i) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if(Wall[x][y][i]) continue;
                if(Maze[nx][ny] != -1) continue;
                tsk.push(make_pair(nx*w + ny, p.second + 1));
                Maze[nx][ny] = p.second + 1;
            }
        }
        //cout << "max_queue: " << max_queue << endl;
        /*
        if(w == 2 && h == 3) {
            for(int i = 0; i < h; ++i) {
                for(int j = 0; j < w; ++j) {
                    cout << Maze[i][j] << " ";
                }
                cout << endl;
            }

        }
        */
        // ゴールは(h-1, w-1)
        cout << ((Maze[h-1][w-1] != -1) ? Maze[h-1][w-1] + 1 : 0 ) << endl;
    }
}


Measured memory_bytes: 3148
use proconio::*;
use proconio::marker::*;

const F: usize = 26;

#[derive(Default)]
struct Node {
    cnt: [u32; F],
    next: [usize; F],
}

fn run() {
    input! {
        n: usize,
        mut s: [Bytes; n],
    }
    s.sort_by_key(|s| s.len());
    let mut node = vec![Node::default()];
    let empty = 0;
    let root = 0;
    let mut ans = 0;
    for s in s.iter_mut().rev() {
        s.reverse();
        let mut now = root;
        let mut stack = vec![];
        for c in s.iter() {
            let k = (*c - b'a') as usize;
            if node[now].next[k] == empty {
                let len = node.len();
                node.push(Node::default());
                node[now].next[k] = len;
            }
            stack.push(now);
            now = node[now].next[k];
        }
        let mut bit = 0;
        for (i, c) in s.iter().rev().enumerate() {
            let parent = stack.pop().unwrap();
            let k = (*c - b'a') as usize;
            if i == 0 {
                ans += node[parent].cnt[k] as usize;
            }
            bit |= 1 << k;
            for (j, cnt) in node[parent].cnt.iter_mut().enumerate() {
                *cnt += ((bit >> j) & 1) as u32;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 308360
#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-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
ll a[1 << 18];
map<ll, int> mp;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	rep(i, n) {
		cin >> a[i]; mp[a[i]]++;
	}
	sort(a, a + n, greater<ll>());
	int out = 0;
	rep(i, n) {
		if (!mp[a[i]])continue;
		per(j, 31) {
			ll k = (ll)1 << j;
			if (k < a[i])break;
			if ((a[i]!=k-a[i]&&mp[k - a[i]])||(a[i]==k-a[i])&&mp[a[i]]>=2) {
				out++;
				mp[a[i]]--; mp[k - a[i]]--;
				break;
			}
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 40192
def eratos(n):
    isPrime = [True]*(n+1)
    isPrime[0] = isPrime[1] = False
    for i in range(3,n+1,2):
        if isPrime[i]:
            for j in range(2*i,n+1,i): isPrime[j] = False
    for i in range(4,n+1,2): isPrime[i] = False
    return isPrime

def isLikeNum(x):
    if x%2 == 0: return False
    if isPrime[x] and isPrime[(x+1)//2]: return True
    else: return False

q = int(input())
l = [0]*q
r = [0]*q
for i in range(q):
    x,y = map(int,input().split())
    l[i] = x
    r[i] = y
m = max(r)
isPrime = eratos(m)
cnt = [0]*(m+1)
for i in range(3,m+1):
    cnt[i] = cnt[i-1]
    if isLikeNum(i): cnt[i] += 1
for i in range(q): print(cnt[r[i]]-cnt[l[i]-1])

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

sabun=[B[i]-A[i] for i in range(N)]
sabun.sort()
num=0
for n in sabun:
    if n<0:
        num+=n
    else:
        num+=n//2
print("Yes" if num>=0 else "No")


Measured memory_bytes: 41328
n = gets.to_i
s = gets.chomp
gets
candidates = gets.split.map(&:to_i)
dp = [1] + [0] * 9
(0..s.size-1).each do |i|
    new_dp = [0] * 10
    (s[i] == ?* ? candidates : [s[i].to_i]).each do |c|
        if (s.size - i).even?
            c = (c * 2).to_s.split("").map(&:to_i).inject(:+)
        end
        (0..9).each do |j|
            new_dp[(j + c) % 10] += dp[j]
        end
    end
    dp = new_dp
end
p dp[0]


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

int main()
{
	int N, A, B,ans = 0,b = 1000000001;

	cin >> N;

	for (int n = 0; n < N; n++) {
		cin >> A >> B;
		if (ans < A)ans = A;
		if (B < b)b = B;
	}

	for (; b > 0; b--)
		ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
	int n,i,j,temp,a,b,c,d,e[100],f[100],g[100];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		e[i]=0;
		f[i]=i;
	}
	for(i=0;i<n*(n-1)/2;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d){
			e[a]=e[a]+3;
		}
		else if(c<d){
			e[b]=e[b]+3;
		}
		else if(c==d){
			e[a]=e[a]+1;
			e[b]=e[b]+1;
		}
	}
	for(i=1;i<=n;i++){
		g[i]=e[i];
	}
	for(i=0;i<n;i++){
		for(j=n;j>i+1;j--){
			if(e[j]>e[j-1]){
				temp=e[j];
				e[j]=e[j-1];
				e[j-1]=temp;
			}
		}
	}
	for(j=2;j<=n;j++){
		if(e[j]==e[j-1]){
			f[j]=f[j-1];
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(g[i]==e[j]){
				printf("%d\n",f[j]);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2736
# 2019-11-18 23:58:23(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n = int(sys.stdin.readline().rstrip())
    ans = math.ceil(n / 2) / n
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
N, M = map(int, input().split())
S = input()

steps = []
c = N
flg = True
while flg:
    if c <= M:
        steps.append(c)
        break
    
    for i in reversed(range(1, M + 1)):
        if S[c - i] == "0":
            steps.append(i)
            c -= i
            break
        if i == 1:
            steps = [-1]
            flg = False
            
print(*steps[::-1])


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

int main(){
  int N;
  cin >> N;
  
  for (int i = 1; i < 10; i++){
    for (int j = 1; j < 10; j++){
      if (i * j == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
}


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


int main() {
   int A,B,K;
   cin>>A>>B>>K;
   rep(i,100){
       if(A%(100-i)==0&&B%(100-i)==0){
           K--;
       }
       if(K==0){
           cout<<100-i<<endl;
          break;
       }
   }
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
    int i,j,H,W;
    while(1){
    cin>>H>>W;
    if(H==0&&W==0)break;
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cout<<"#";
        }
        cout<<endl;
    }
    cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
# -*- Coding: utf-8 -*-
import math

def is_prime(x):
    if x <=1:
        return False

    for i in range(2, int(math.sqrt(x)+1)):
        if x%i == 0:
            return False
    
    return True

x = int(input())

while(not is_prime(x)): x+=1

print(x)

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

int main(){
	int a[100001] = {}, b[100001] = {}, n ,count = 0;
	cin >> n;
	for(int i = 1;i<=n;i++){
		cin >> a[i];
	}
	n = 1;
	while(true){
		if (!b[n] && n != 2) b[n]++;
		else if (n == 2) {
			cout << count << endl;
			break;
		}
		else {
			cout << -1 << endl;
			break; 
		}
		count++;
		n = a[n];
	}
	return 0;
}

Measured memory_bytes: 1024
#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") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const char Q = '?';
    string s, t;
    cin >> s >> t;
    bool solve;
    for(int i = s.size()- t.size()+1; i >= 0; i--) {
        solve = true;
        REP(j,t.size()) {
            if (s[i+j] == Q) continue;
            if (s[i+j] != t[j]) {
                solve = false;
                break;
            }
        }
        if (solve) {
            REP(j,t.size()) s[i+j] = t[j];
            break;
        }
    }
    REP(i,s.size()) s[i] = (s[i] == Q) ? 'a' : s[i];

    if (solve) cout << s << endl;
    else cout << "UNRESTORABLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;
typedef pair<int,int> P;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  int64_t n;
  cin >> n;
  vector<int> vec(n);
  int mx = INT_MIN;
  int mx2 = INT_MIN;
  REP(i,n){
    cin >> vec.at(i);
    if (mx <= vec.at(i)){
      mx2 = mx;
    }else if (mx >= vec.at(i) && mx2 < vec.at(i)){
      mx2 = vec.at(i);
    }
    mx = max(mx, vec.at(i));
  }
  REP(i,n){
    if (vec.at(i) != mx){
      cout << mx << endl;
    }else{
      cout << mx2 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 2432
n, m = map(int, input().split())

edges = [ [] for _ in range(n) ]

for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

INF = 10 ** 6

def dijkstra_travel(edges):
    dists = [ INF  for _ in range(n) ]
    paths = [ None for _ in range(n) ]

    dists[0] = 0
    paths[0] = 0

    next_travel = [ 0 ]

    def travel_adjacent():
        n = next_travel.pop(0)

        adjacent_nodes = list(
            map(
                lambda node: (node, paths[node]),
                edges[n],
            )
        )

        for node, path in adjacent_nodes:
            if path is None or dists[node] > dists[n] + 1:
                dists[node] = dists[n] + 1
                paths[node] = n
                next_travel.append(node)


    while len(next_travel) > 0:
        travel_adjacent()

    return paths[1:]

result = dijkstra_travel(edges)

if all(map(lambda x: x is not None, result)):
    print('Yes')

    for x in result:
        print(x + 1)

else:
    print('No')

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

int main() {
  double N, K;
  cin >> N >> K;
  double rate = 0;
  for (int i = 1; i <= N; i++) {
    int cnt = 0;
    int point = i;
    while (point < K) {
      point *= 2;
      cnt++;
    }
    rate += (1/N) * pow(0.5, cnt);
  }
  cout << fixed << setprecision(12);
  cout << rate << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)


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

	if(n%1000 == 0) cout << 0 << endl;
	else cout << 1000-(n%1000) << endl;

	return 0;
}

Measured memory_bytes: 3620
#F
N,S=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353

dp=[[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0]+=1
for i in range(N):
    for j in range(S+1):
        dp[i+1][j]+=2*dp[i][j]
        dp[i+1][j]%=mod
        if j+A[i]<=S:
            dp[i+1][j+A[i]]+=dp[i][j]
            dp[i+1][j+A[i]]%=mod            
print(dp[N][S])

Measured memory_bytes: 147500
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  double l; cin>>l;
  cout << l/3*l/3*l/3;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)


bool chooseIntegers(int a, int b, int c) {
	FOR(i, 2, b + 2) {
		if (a*i % b==c) {
			return true;
		}
	}
	return false;
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((chooseIntegers(a, b, c))?"YES":"NO") << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String at = sc.next();
        String top = sc.next();
        
        String ans = "";
        
        if(at.equals("H")){
           ans = top;
        }else{
            if(top.equals("H")){
                ans = "D";
            }else{
                ans = "H";
            }
        }
         
        System.out.println(ans);
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(int a,int b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(int a,int b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  string s,t;
  cin>>s>>t;
  sort(all(s)); 
  sort(all(t)); 
  reverse(all(t)); 
  int mi=min(len(s),len(t));
  rep(i,mi){
    if(s[i]>t[i]){
      cout<<"No"<<endl;
      return 0;
    }
    if(s[i]<t[i]){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(s[i]==t[i]) continue;
  }
  if(len(s)>=len(t)){
    cout<<"No"<<endl;
  }
  if(len(s)<len(t)){
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<int, pii> pipii;

bool piisort(pii a, pii b) {
  return a.first - b.second > b.first - a.second;
}

pii l[100005];
void solve() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> l[i].first >> l[i].second;
  }
  sort(l, l+n, piisort);
  ll ret = 0;
  for(int i = 0; i < n; i++) {
    if(i%2) ret -= l[i].second;
    else ret += l[i].first;
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(){
    int x;
    for(int i = 0; i < 10000; i ++){
        scanf("%d", &x);
        if(x == 0){
            break;
        }
        printf("Case %d: %d\n", i + 1, x);
    }
    return 0;
}

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

int main(){
    int N,L;
    // L+i-1
    cin >> N >> L;
    int sum = L*N+N*(N+1)/2-N;
    //cout << "sum " << sum << endl;
    int tmp,ans;

    for(int i=0; i<N; i++){
        tmp=sum-(L+i);
        if(i==0){
            ans=tmp;
        }else if(abs(sum-tmp)<abs(sum-ans)){
            ans=tmp;
        }
        //cout << "i ans " << i << " " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;using System.Linq;
class ast{ static void Main(){


int n=int.Parse(Console.ReadLine());
for(int i=0;i<n;i++)
{int []a=Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(a[0]%a[1]==0?a[1]:a[0]%a[1]);
}





}}

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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7;

lint Ans=0;
int n;

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		Ans+=(n-1)/i;
	}
	printf("%lld\n",Ans);

	return 0;
}

Measured memory_bytes: 3824
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    vector<ll> a;
    vector<vector<vector<ll> > > dp;

    void input() {
        cin >> N;
        a.resize(N);
        rep(i, 0, N) cin >> a[i];
        dp.resize(N, vector<vector<ll>>(N, vector<ll>(2, -1)));

    }

    ll rec(int s, int t, int u) {
        if (dp[s][t][u] != -1) return dp[s][t][u];

        if (s == t) {
            if (u == 0)
                return dp[s][t][u] = a[s];
            else
                return dp[s][t][u] = -a[s];
        }

        if (u == 0) {
            //最大化
            ll val1 = rec(s + 1, t, 1) + a[s];
            ll val2 = rec(s, t - 1, 1) + a[t];

            return dp[s][t][u] = max(val1, val2);
        } else {
            //最小化
            ll val1 = rec(s + 1, t, 0) - a[s];
            ll val2 = rec(s, t - 1, 0) - a[t];

            return dp[s][t][u] = min(val1, val2);
        }

    }

    void solve() {
        input();
        ll ans = rec(0, N - 1, 0);
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 492928
from heapq import*
(n,m,s),*t=[map(int,t.split())for t in open(0)]
*e,=eval('[],'*8**6)
for u,v,a,b in t[:m]:
    for i in range(2501-a):
        e[(i+a)*51+u]+=(b,i*51+v),
        e[(i+a)*51+v]+=(b,i*51+u),
for i,(c,d)in enumerate(t[m:],1):
    for j in range(2501-c):
        e[j*51+i]+=(d,(j+c)*51+i),
d=[10**18]*8**6
f=[1]*8**6
q=[(0,min(2500,s)*51+1)]
while q:
    c,v=heappop(q)
    if f[v]<1:continue
    d[v],f[v]=c,0
    for p,w in e[v]:
        if f[w]:heappush(q,(c+p,w))
for i in range(2,n+1):print(min(d[i::51]))

Measured memory_bytes: 390776
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  const int MAX_X = 1250;
  for(int x = 1; x <= MAX_X; x++) {
    if((8 * x) / 100 == a && (10 * x) / 100 == b) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.LongUnaryOperator;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum =0;
        for(int i=1;i<=n;i++){
            if ((i%3!=0)&&(i%5!=0)){
                sum += i;
            }
        }
        System.out.println(sum);
        }
        }


Measured memory_bytes: 35708
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

vector<int> ans(100010);
int k = 0;

void dfs(int cv, int pv, int pnum, vector<vector<P>> &G){
    int cnt = 0;
    for(auto nxt : G[cv]){
        int nv, index;
        tie(nv, index) = nxt;

        if(nv == pv) continue;

        ans[index] = (pnum + 1 + cnt) % k;
        dfs(nv, cv, (pnum + 1 + cnt) % k, G);
        cnt++;
    }

    return ;
}

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

    int n; cin>>n;
    vector<vector<P>> G(n);
    vector<int> cnt(n, 0);
    for(int i=0; i<n-1; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        cnt[a]++;
        cnt[b]++;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }

    for(int i=0; i<n; i++){
        chmax(k, cnt[i]);
    }

    dfs(0, -1, -1, G);

    cout << k << endl;
    for(int i=0; i<n-1; i++) cout << ans[i] + 1 << endl;

    return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll a[100002] = {};
ll s[100002] = {};
int main() {
	ll n; cin >> n;
	//ll ml = 0, mr = 1 << 21;
	ll sum = 0;
	repe(i, 1, n) {
		cin >> a[i];
		//ml = max(ml, a[i]);
		//mr = min(mr, a[i]);
		s[i] = a[i] - a[i - 1];
		sum += abs(a[i] - a[i - 1]);
	}
	s[n + 1] = -a[n];
	sum += abs(a[n]);
	repe(i, 1, n) {
		if (a[i-1] <= a[i] && a[i] <= a[i + 1] &&
			a[i-1] >= a[i] && a[i] >= a[i+1]){ 
			cout << sum << endl;
		}
		else {
			ll b = abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
			ll c = abs(a[i - 1] - a[i + 1]);
			cout << sum - (b - c) << endl;
		}
	}

	return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    bool ok = false;

    rep(x, 10000) {
        int y7 = n - 4 * x;
        if (y7 % 7 == 0 && y7 >= 0) ok = true;
    }
    Yes(ok);
    return 0;
}

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        es: [(usize1, usize1, usize); n - 1],
        q: usize,
        k: usize1,
        qs: [(usize1, usize1); q]
    }
    let mut t = vec![vec![]; n];
    for &(a, b, c) in &es {
        t[a].push((b, c));
        t[b].push((a, c));
    }
    let mut d = vec![1 << 60; n];
    d[k] = 0;
    let mut q = VecDeque::new();
    q.push_back((k, k));
    while let Some((u, p)) = q.pop_front() {
        for &(v, c) in &t[u] {
            if v == p {
                continue;
            }
            d[v] = d[u] + c;
            q.push_back((v, u));
        }
    }
    for &(x, y) in &qs {
        println!("{}", d[x] + d[y]);
    }
}


Measured memory_bytes: 27900
// insertion sort

#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

void display(vector<int> const &v)
{
    rep(i, v.size())
    {
        if(i > 0) cout << " ";
        cout << v.at(i);
    }
    cout << endl;
}

void insertionSort(vector<int> &v, int & N)
{
    display(v);
    rep2(i, 1, N)
    {
        int temp = v.at(i);
        int j = i - 1;
        while(j >= 0 && v.at(j) > temp)
        {
            v.at(j+1) = v.at(j);
            --j;
        }
        v.at(j+1) = temp;
        display(v);
    } 
}

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v.at(i);
    // int N = 6;
    // vector<int> v{5,2,4,6,1,3};
    insertionSort(v, N);

    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
//#include <algorithm>
#include<set>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  string s;
  cin >> s;
  vector<int> snum(3,0);
  rep(i,s.size()){
    snum[s[i]-'a']+=1;
  }
  int minsnum=min(snum[0],snum[1]);
  minsnum=min(snum[2],minsnum);
  snum[0]-=minsnum;
  snum[1]-=minsnum;
  snum[2]-=minsnum;
    if(snum[0]>=2||snum[1]>=2||snum[2]>=2){
      cout<<"NO"<<endl;
    }else{
      cout<<"YES"<<endl;
    }
  return 0;
}

Measured memory_bytes: 512
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}

#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
#define int long long

const int N = (int)(1e6) + 322;
const int inf = (int)(2e18);
const int mod = (int)(1e9) + 7; // check modulo
const double eps = (1e-6);

int cnt[N], a[N];
char str[N];

void solve(int test) {
        int n; cin >> n;
        int i = 0; // To store current index in str which is result

        while (n > 0) {
            // Find remainder
            int rem = n % 26;

            // If remainder is 0, then a 'Z' must be there in output
            if (rem == 0) {
                str[i++] = 'z';
                n = (n / 26) - 1;
            }
            else // If remainder is non-zero
            {
                str[i++] = (rem - 1) + 'a';
                n = n / 26;
            }
        }
        str[i] = '\0';

        // Reverse the string and print result
        reverse(str, str + strlen(str));
        cout << str << endl;

}

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int test = 1;// cin >> test;
    for(int tt = 1; tt <= test; ++tt) {
        solve(tt);
    }


    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
const int mod=1e9+7;
char ch[MAXN];
int vis[30];
int main()
{
  int len;scanf("%d",&len);
  scanf("%s",ch+1);
  for(int i=1;i<=len;i++)vis[ch[i]-'a'+1]++;
  int ans=1;
  for(int i=1;i<=26;i++)ans=1LL*ans*(vis[i]+1)%mod;
  ans--;if(ans<0)ans+=mod;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 384
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A&lang=jp

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

#define MAX_V 1000
const int INF = 1 << 30;

//辺を表す構造体(行先，容量，逆辺)
struct edge{
  int to, cap, rev;
};

vector<edge> G[MAX_V];
bool used[MAX_V];

//辺の追加
void add_edge(int from, int to, int cap){
  G[from].push_back(edge{to, cap, (int)G[to].size()});
  G[to].push_back(edge{from, 0, (int)G[from].size() - 1});
}

//増加パスをDFSで探す
int dfs(int v, int t, int f){
  if(v == t) return f;
  used[v] = true;
  for(int i = 0; i < (int)G[v].size(); i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

//sからtへの最大流を求める
int max_flow(int s, int t){
  int flow = 0;
  for(;;){
    fill(used, used + MAX_V, false);
    int f = dfs(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(){
  int X, Y, M;
  cin >> X >> Y >> M;

  int s = X + Y + 1;
  int t = X + Y + 2;

  for(int i = 0; i < X; i++){
    add_edge(s, i, 1);
  }
  for(int i = 0; i < Y; i++){
    add_edge(i + X, t, 1);
  }

  for(int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y;
    y += X;

    add_edge(x, y, 1);
  }

  cout << max_flow(s, t) << endl;
  return 0;
}


Measured memory_bytes: 3296
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a=sc.nextInt();
    System.out.println(a%10+(a/10)%10+(a/100)%10);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
 
int main(void){
  int x;
  scanf("%d",&x);
  
  int c500 = x/500;
  int r500 = x%500;
  int c5 = r500/5;
  
  printf("%d\n", 1000*c500+5*c5);
  
  return 0;
}

Measured memory_bytes: 1724
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        s: [chars; n],
    }
    let mut dp = vec![0; n];
    dp[0] = 1;
    let mut stack = vec![0];
    while let Some(v) = stack.pop() {
        for u in 0..n {
            if s[v][u] == '0' {
                continue;
            }
            if dp[u] == 0 {
                dp[u] = 1 + 2 - dp[v];
                stack.push(u);
            } else if dp[u] == dp[v] {
                println!("-1");
                return;
            }
        }
    }
    let mut d = vec![vec![n; n]; n];
    for i in 0..n {
        for j in 0..n {
            if s[i][j] == '1' {
                d[i][j] = 1;
            } else if i == j {
                d[i][j] = 0;
            }
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d[i][j] = std::cmp::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    let ans = 1 + d.iter().map(|d| d.iter().max().unwrap()).max().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include<cstdio>
typedef long long ll;
const int mod=1000000007;
int N,K,fac[4010],ifac[4010];
ll inv(int a,int p=mod){return a==1?1:(1+p*(a-inv(p%a,a)))/a%p;}
int C(int n,int m){return m<0||m>n?0:1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
int main(){
	scanf("%d%d",&N,&K);
	for(int i=*fac=1;i<=N+K;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[N+K]=inv(fac[N+K]);
	for(int i=N+K;i;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	int ans=(C(N+K-2,N-1)-C(N+K-2,N)+mod)%mod;
	for(int i=N-K;--i>0;)ans=ans*2%mod;
	printf("%d\n",ans);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  int max,min;
  max = 0;
  min = 1000000000;
    
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
    
    if (max < vec.at(i)) max = vec.at(i);
    
    if (min > vec.at(i)) min = vec.at(i);
  }
 
  cout << max - min << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	l := make([]int, n)

	for i := 0; i < n; i++ {
		l[i] = nextInt()
	}
	sort.Ints(l)
	cnt := 0
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			for k := j; k < n; k++ {
				if l[i] == l[j] || l[k] == l[j] || l[i] == l[k] {
					continue
				}
				if l[i]+l[j] > l[k] {
					cnt++
				}
			}
		}
	}

	fmt.Println(cnt)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <cmath>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;

  int n;
  int d;
  cin >> n >> d;

  vector<vector<int>> a(n, vector<int>(d));
  for (auto&& i : a) {
    for (auto&& j : i)
      cin >> j;
  }

  int ans = 0;

  for (int i = 0; i < n; ++i) {

    for (int j = i + 1; j < n; ++j) {
      int sum = 0;

      for (int k = 0; k < d; ++k)
        sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);

      int temp = sqrt(sum);

      if (temp * temp == sum)
        ++ans;
    }
  }

  cout << ans;
}


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

typedef long long ll;

const ll MOD = 1e9 + 7;

int main() {
    ll N, K, R, S, P, ans = 0, prev = -1;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    rep(i, K) {
        prev = -1;
        for (int j = i; j < N; j += K) {
            if (T[j] == 'r') {
                if (prev == 2) {
                    prev = -1;
                } else {
                    ans += P;
                    prev = 2;
                }
            } else if (T[j] == 's') {
                if (prev == 0) {
                    prev = -1;
                } else {
                    ans += R;
                    prev = 0;
                }
            } else {
                if (prev == 1) {
                    prev = -1;
                } else {
                    ans += S;
                    prev = 1;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
ans = sum(a)

i = 0
while ans % 10 == 0:
    if i >= n-1:
        ans = 0
        break
    if a[i] % 10 != 0:
        ans -= a[i]
    i += 1

print(ans)

Measured memory_bytes: 3060
while True:
    m, n_min, n_max = map(int, input().split())
    if m == 0 and n_min == 0 and n_max == 0:
        break
    P = [0 for i in range(m)]
    for i in range(m):
        P[i] = int(input())
    
    P.sort()
    ans = 0
    ans_gap = 0
    prev = P[m - n_max - 1] 
    
    for i in range(m - n_max, m - n_min + 1):
        if P[i] != prev:
            if ans_gap < (P[i] - P[i - 1]):
                ans_gap = P[i] - P[i - 1]
                ans = m - i
        prev = P[i]
    
    print(ans)


Measured memory_bytes: 5624
import sys
n, hl = sys.stdin.readlines()
n = int(n)
hl = list(map(int, hl.split()))

for i in range(n-1, 0, -1):
    if hl[i] - hl[i-1] ==-1:
        hl[i-1]-=1

if hl == sorted(hl):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 15284
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int L = scan.nextInt();
		int R = scan.nextInt();
		int d = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = L; i < R + 1; i++) {
			list.add(i);
		}
		int count = 0;
		for (int i : list) {
			if (i % d == 0) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 27072