akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double dx[11];
double dy[11];
double dv[11];
int ret[11];
double eps=1e-7;
double fx[1100];
double fy[1100];
double vx[1100];
double vy[1100];
double tx[11];
double ty[11];
double ABS(double a){return max(a,-a);}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++){
			scanf("%lf%lf%lf",dx+i,dy+i,dv+i);
		}
		for(int i=0;i<a;i++)ret[i]=0;
		for(int i=0;i<b;i++){
			scanf("%lf%lf%lf%lf",fx+i,fy+i,vx+i,vy+i);
		}
		for(int i=0;i<b;i++){
			double val=999999999;
			int at=-1;
			for(int j=0;j<a;j++){
				if((dx[j]-fx[i])*(dx[j]-fx[i])+(dy[j]-fy[i])*(dy[j]-fy[i])<eps)at=j;
			}
			if(~at){
				ret[at]++;continue;
			}
			for(int j=0;j<a;j++)tx[j]=ty[j]=0;
			for(int j=0;j<a;j++){
				double A=vx[i]*vx[i]+vy[i]*vy[i]-dv[j]*dv[j];
				double B=2.0*((fx[i]-dx[j])*vx[i]+(fy[i]-dy[j])*vy[i]);
				double C=(fx[i]-dx[j])*(fx[i]-dx[j])+(fy[i]-dy[j])*(fy[i]-dy[j]);
				double t;
				if(ABS(A)<eps){
					if(ABS(B)<eps)continue;
					t=-C/B;
				}else if(B*B-A*C*4>-eps){
					t=(-B-sqrt(max(0.0,B*B-A*C*4)))/A/2;
					if(t<0)t=(-B+sqrt(max(0.0,B*B-A*C*4)))/A/2;
				}else continue;
				if(t<0)continue;
				if(val>t){
					val=t;at=j;
				}
				double sx=fx[i]+vx[i]*t;
				double sy=fy[i]+vy[i]*t;
				tx[j]=(sx-dx[j])/t;
				ty[j]=(sy-dy[j])/t;
			}
			ret[at]++;
			for(int j=0;j<a;j++){
				dx[j]+=val*tx[j];
				dy[j]+=val*ty[j];
			}
		}
		for(int i=0;i<a;i++){
			if(i)printf(" ");
			printf("%d",ret[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1108
while 1:
    s=input()
    if s=='.':
        break
    stk=[]
    try:
        for c in s:
            if c in '([':
                stk.append(c)
            elif c == ')' and stk[-1]=='(':
                del stk[-1]
            elif c == ']' and stk[-1]=='[':
                del stk[-1]
            elif c in '()[]':
                print('no')
                break
        else:
            if len(stk)==0:
                print('yes')
            else:
                print('no')
    except:
        print('no')
        


Measured memory_bytes: 5580
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, M) = Slice2<long>();
            var nab = new (long a, long b)[M];
            for (var i = 0; i < M; ++i)
                nab[i] = Slice2<long>();
            Array.Sort(nab);
            var cnt = 1L;
            var l = long.MaxValue;
            for (var i = 0; i < M; ++i)
            {
                var (a, b) = nab[i];
                if (l <= a)
                {
                    ++cnt;
                    l = long.MaxValue;
                }
                l = Min(l, b);
            }
            WriteLine(cnt);
        }
 
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 47932
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/ /);

const main = input => {
  const A = input.map(x => Number(x));
  const arr = A.sort((x, y) => y - x);
  const ans = arr[0] - arr[2];
  console.log(ans);
};

main(receive);


Measured memory_bytes: 7372
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

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

	if n > k {
		r := n % k
		diff := (r - k)
		if r < diff*(-1) {
			fmt.Println(r)
			return
		} else {
			fmt.Println(diff * (-1))
			return
		}
	} else {
		diff := (n - k)
		if n < diff*(-1) {
			fmt.Println(n)
			return
		} else {
			fmt.Println(diff * (-1))
			return
		}
	}
}


Measured memory_bytes: 1756
s = input()

acgt = "ACGT"
s_list = list(s)

cur_len = 0
max_len = 0

for c in s_list:
    if c in acgt:
        cur_len += 1
        if max_len < cur_len:
            max_len = cur_len
    else:
        cur_len = 0

print(max_len)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    for(int i=1; i<1500; i++){
        if(i*8 / 100 == a && i/10 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n;
ll a[1000000];
ll sum;
ll nim = INF;
ll ans;
int cnt;

int main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a[i];
        if (a[i]>0) {
            sum += a[i];
            nim = min(nim,a[i]);
        } else {
            sum -= a[i];
            nim = min(nim,-a[i]);
            cnt++;
        }
        // cout << sum << " " << a[i] << endl;
    }
    // sum は絶対値のわ
    if(cnt%2 != 0) ans = sum - (2*nim);
    else ans = sum;
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Graph g = new Graph();
		g.loadAdjList();
		g.BFS(0);

	}

}

class Graph {
	
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
}
	int[] distances;
	int[] visited;
public void printAdjMatrix() {
	Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
	//complete the following
	for(int i = 0; i < totalVertex; i++) {
		for(int j = 0; j < totalVertex; j++) {
			adjMatrix[i][j] = 0;
		}
	}
	for(int i = 0; i < totalVertex; i++) {
		for(int j = 0; j < adjList.get(i).size(); j++) {
				adjMatrix[i][adjList.get(i).get(j)] = 1;
		}
	}
	for(int i = 0; i < totalVertex; i++) {
		for(int j = 0; j < totalVertex - 1; j++) {
			System.out.print(adjMatrix[i][j] + " ");
		}
		System.out.println(adjMatrix[i][totalVertex - 1]);
	}
}

public void BFS(int v) {
	int[] distances = new int[adjList.size()];
	int[] visited = new int[adjList.size()];
	//LinkedList<Integer> nb = adjList.get(v);
	Queue<Integer> vertexes = new LinkedList<Integer>();
	vertexes.add(v);
	visited[v] = 1;
	while(true) {
		int next = vertexes.poll();
		for(int j = 0; j < adjList.get(next).size(); j++) {
			if(visited[adjList.get(next).get(j)] == 0) {
				vertexes.add(adjList.get(next).get(j));
				distances[adjList.get(next).get(j)] = distances[next] + 1;
				visited[adjList.get(next).get(j)] = 1;
			}
		}
		if(vertexes.isEmpty()) {
			break;
		}
	
	}
	for(int i = 0; i < distances.length; i++) {
		if(visited[i] == 0) {
			distances[i] = -1;
		}
		System.out.println(i+1 +  " " + Integer.toString(distances[i]));
	}

}


/*public void BFS(int v, int d0) {
	distances = new int[adjList.size()];
	visited = new int[adjList.size()];
	
	int d = d0;
	Queue<Integer> nb = adjList.get(v);
	while(!nb.isEmpty()) {
		int w = nb.poll();
		if(visited[w] == 0) {
			visited[w] = 1;
			distances[w] = d + 1;
			d++;
		}
	}
	for(int i = 0; i < distances.length; i++) {
		System.out.println(distances[i]);
	}
	//distances[v] = d;
	//return distances[v];
}*/


}



Measured memory_bytes: 28364
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, S, ans;
    int[] magic;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    S = sc.nextInt();
	    if(n==0 && S==0) break;
	    magic = new int[n];
	    for(int i=0; i<n; i++)
		magic[i] = sc.nextInt();
	    ans = 0;
	    solve();
	    System.out.println(ans);
	}
    }

    void solve(){
	Arrays.sort(magic);
	for(int i=n-1; i>=0; i--){
	    if(magic[i]>=S) ans += i;
	    else if(magic[i]<S/2) break;
	    else if(i>0){
		ans += search(0, i-1, i);
	    }
	    //System.out.println(i+" "+ans);
	}
    }
    
    int search(int left, int right, int x){
	int mid = (left+right)/2;
	while(left<=right){
	    if(magic[mid]+magic[x] > S) right = mid-1;
	    else left = mid+1;
	    mid = (left+right)/2;
	}
	if(magic[left]+magic[x]<=S) return 0;
	return x-left;
    }
}

Measured memory_bytes: 158404
n,k=gets.split;a=[*0..9]-gets.split.map(&:to_i)
idx1=(0...n.size).find{|i|!a.find{|e|e==n[i].to_i}}
(puts n;exit)if !idx1
idx2=idx1.downto(0).find{|i|a.find{|e|e>n[i].to_i}}||-1
if idx2<0
$><<(a[0]>0 ? a[0] : a[1])
else
$><<n[0...idx2]<<a.find{|e|e>n[idx2].to_i}
end
puts a[0].to_s*(n.size-idx2-1)

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

int main(void) {
	int A, B;
	scanf("%d%d", &A, &B);
	int ans = -1;
	for (int i = 1; i <= 1300; i++) {
		if (i*8/100 == A && i*10/100 == B) {
			ans = i;
			break;
		}
	}
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 3824
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

struct UF
{
    long         num;
    vector<long> par;
    vector<long> rank;

    UF(long n): num(n) {
        par.resize(n);
        rank.resize(n);
        long i;
        for(i=0; i<n; i++) {
            par[i]=i;  rank[i]=1;
        }
    }
	
    long find(long x) {
        if(x==par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(long x, long y) {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(long x, long y) {
        return find(x)==find(y);
    }

    long ngroup() {
        long count=0;
        long i;
        for(i=0; i<num; i++) {
            if(par[i]==i) count++;
        }
        return count;
    }
};


int main(int argc, char* argv[])
{
    long n, k, l;
    scanf("%ld%ld%ld", &n, &k, &l);

    UF uf0(n);
    UF uf1(n);

    long i;
    for(i=0; i<k; i++) {
        long x, y;
        scanf("%ld%ld", &x, &y);
        uf0.unite(x-1, y-1);
    }
    for(i=0; i<l; i++) {
        long x, y;
        scanf("%ld%ld", &x, &y);
        uf1.unite(x-1, y-1);
    }

    map<pair<long, long>, long> zz;
    for(i=0; i<n; i++) {
        zz[make_pair(uf0.find(i), uf1.find(i))]++;
    }
    for(i=0; i<n; i++) {
        printf("%ld", zz[make_pair(uf0.find(i), uf1.find(i))]);
        if(i==n-1) printf("\n");
        else       printf(" ");
    }


    return 0;
}



Measured memory_bytes: 18048
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main implements Runnable{
	int N,X,Y;
	int[] a,b,c,d;
	int[][][] dp;

	public int dfs(int n,int x,int y){

		if(n >= N){
			if(x < 300 || y < 300)return -1;
			return 0;
		}

		if(dp[n][x][y] != Integer.MIN_VALUE){
			return dp[n][x][y];
		}

		int ret = -1;

		{
			int tmp = dfs(n + 1,x - a[n],y + b[n]);
			if(tmp != -1){
				ret = Math.max(ret,tmp);
			}
		}

		{
			int tmp = dfs(n + 1,x,y - c[n]);

			if(tmp != -1){
				ret = Math.max(ret,tmp + d[n]);
			}
		}

		{
			int tmp = dfs(n + 1,x,y);

			if(tmp != -1){
				ret = Math.max(ret,tmp);
			}
		}
		return dp[n][x][y] = ret;
	}

	public void solve() {
		N = nextInt();
		X = nextInt();
		Y = nextInt();


		a = new int[N];
		b = new int[N];
		c = new int[N];
		d = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
			b[i] = nextInt();
			c[i] = nextInt();
			d[i] = nextInt();
		}

		dp = new int[N][901][901];
		for(int i = 0;i < N;i++){
			for(int j = 0;j < 901;j++){
				for(int k = 0;k < 901;k++){
					dp[i][j][k] = Integer.MIN_VALUE;
				}
			}
		}
		int ans = dfs(0,X + 300,Y + 300);
		out.println(ans == -1 ? 0 : ans);
	}

	public static void main(String[] args) {
		new Thread(null,new Main(),"",32 * 1024 * 1024).start();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	@Override
	public void run() {
		out.flush();
		new Main().solve();
		out.close();

	}
}

Measured memory_bytes: 442988
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string str;
    cin >> str;

    size_t size = str.length();

    int preans = 0;
    int ans = 0;
    for(int i=0; i<(int)size; i++){
        str[i];
        if(str[i]=='A' || str[i]=='T' || str[i]=='G' || str[i]=='C'){
            preans += 1;
            ans = max(preans, ans);
        }else{
            ans = max(preans, ans);
            preans *= 0;
        }
        //ans = max(preans, ans);
        //cout << preans << "," << ans << "\n"; //確認用
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 update : k を x に変更
 query : [s,t) の最小(大)を出力する
 */
const ll INIT = INT_MAX;
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
    }
    
    ll merge(ll l,ll r){
        return min(l,r);
    }
    void update(int k, ll val) {
        k += N - 1;
        node[k] = val;
        while (k) {
            k = (k - 1) / 2;
            node[k] = merge(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    ll query(int a,int b){ return query(a,b,0,0,N);}
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return node[k];
        else {
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return merge(vl, vr);
        }
    }
    ll rmq(int a, int b) { return query(a, b, 0, 0, N); }
};



int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    SegTree ST(n);
    int q; cin >> q;
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t; cin >> s >> t;
            ST.update(s,t);
        }else{
            int s,t; cin >> s >> t;
            cout << ST.query(s,t+1) << endl;
        }
    }
}



Measured memory_bytes: 4816
from collections import defaultdict

n = int(input())
dct = defaultdict(int)

for i in range(n):
    s = input()
    sorted_s = "".join(sorted(s))
    dct[sorted_s] += 1

ans = 0
for a, b in dct.items():
    ans += b *(b-1)//2

print(ans)

Measured memory_bytes: 62296
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let n = s.len();
    
    let mut vec: Vec<usize> = vec![0; 26];
    for i in 0..n {
        vec[s[i] as usize - 'a' as usize] += 1;
    }

    let mut sum = 0;
    for i in 0..26 {
        if vec[i] > 0 {
            sum += vec[i] * (vec[i] - 1) / 2;
        }
    }

    println!("{}", 1 + n * (n-1) / 2 - sum);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

ll gcd(ll n, ll m){
    while(true){
        if(n<m) swap(n, m);
        if(!m) break;
        n %= m;
    }
    return n;
}

int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    vll l(n);
    l[0] = a[0];
    REP(i, 1, n){
        l[i] = gcd(l[i-1], a[i]);
    }
    vll r(n);
    r[n-1] = a[n-1];
    IREP(i, n-1, 0){
        r[i] = gcd(r[i+1], a[i]);
    }
    ll m = 0;
    rep(i, n){
        ll t = i>0? (i<n-1? gcd(l[i-1], r[i+1]) : l[i-1]) : r[i+1];
        if(t>m) m = t;
    }
    cout << m << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define forr(i,k,n) for(int i=k; i<n; i++)
#define iforr(i,k,n) for(int i=n-1; i>=k; i--)
#define rep(i,n) forr(i,0,n)
#define irep(i,n) iforr(i,0,n)
#define aut(i,arr) for(auto& i:arr)
#define all(arr) arr.begin(), arr.end()
#define pb push_back
#define pii pair<int,int>
#define vpii vector<pii>
#define f first
#define db double
#define s second
#define ll long long 
#define ull unsigned long long
#define E '\n'
#define lmax 9223372036854775807;
#define MOD 1000000007
using namespace std;
vi v;
vvi ed;
void dfs(int i)
{
	v[i]=1;
	aut(j,ed[i])
		if(!v[j])
			dfs(j);
}
void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("code.in","r",stdin);
    freopen("code.out","w",stdout);
    #endif
}

int main()
{
	//Fast_IO();
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		int n;
		cin>>n;
		int k;
		cin>>k;
		vi arr(n);
		vi dp(n,1e9);
		dp[0]=0;
		rep(i,n)
			cin>>arr[i];
		forr(i,1,n)
			for(int j=i-1;j>=0&&i-j<=k;j--)
				dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
		cout<<dp[n-1];
		cout<<E;
	}
	return 0;
}

Measured memory_bytes: 1024
/*
                                             ::                     ::
                                             ':                     :
                                              :.                    :
                                           ;' ::                   ::  '
                                          .'  ';                   ;'  '.
                                         ::    :;                 ;:    ::
                                         ;      :;.             ,;:     ::
                                         :;      :;:           ,;"      ::
                                         ::.      ':;  ..,.;  ;:'     ,.;:
                                          "'"...   '::,::::: ;:   .;.;""'
                                              '"""....;:::::;,;.;"""
                                          .:::.....'"':::::::'",...;::::;.
                                         ;:' '""'"";.,;:::::;.'""""""  ':;
                                        ::'         ;::;:::;::..         :;
                                       ::         ,;:::::::::::;:..       ::
                                       ;'     ,;;:;::::::::::::::;";..    ':.
                                      ::     ;:"  ::::::"""'::::::  ":     ::
                                       :.    ::   ::::::;  :::::::   :     ;
                                        ;    ::   :::::::  :::::::   :    ;
                                         '   ::   ::::::....:::::'  ,:   '
                                          '  ::    :::::::::::::"   ::
                                             ::     ':::::::::"'    ::
                                             ':       """""""'      ::
                                              ::                   ;:
                                              ':;                 ;:"


                                                     P_r_A_d_Y
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void cs(int &x)
{
    cout << "Case #" << x << ": ";
}
bool cmp(string a, string b)
{
    return a + b < b + a;
}

int32_t main()
{
    fastIO;
    // int t; cin >> t;
    // int x = 1;
    // while (t--)
    // {

        int a,b,n;
        cin>>a>>b>>n;
        int r;

        int i=min(n,b-1);
        double o=((1.0*i)/(1.0*b));
        r=floor(o*a);
            
        

        
        cout<<r<<endl;
    //}
    return 0;
}


Measured memory_bytes: 3680
s = gets.to_i
count = 0
ary = []

loop do
  if ary.include?(s)
    break
  else
    ary << s
  end
  if s % 2 == 1
    s = s * 3 + 1
  else
    s = s / 2
  end
  count += 1
end
puts count + 1


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n;
  vl val(n);
  rep(i,n){
    ll x; cin >> x; val[i] = x;
  }
  
  sort(all(val));
  long double sum = double(val[0]+val[1])/2 ;
  for(ll i=2; i < n; i++){
    sum = double(sum + val[i])/2;
  }
  
  cout << fixed << setprecision(10);
  cout << sum << endl;
}

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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	ll n; cin>>n;
	string s = "";
	while(n>0){
		if(n%26==0){ s = s + 'z'; n = n - 26; n = n/26; }
		else{
			s = s + (char)(n%26-1+'a');
			n = n/26;
		}
	}
	reverse(all(s));
	cout<<s<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

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

int const MAX = 1000001;
int a[MAX];

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        int x;
        cin >> x;
        a[x]++;
    }

    int ans = 0;
    for (int i = 1; i < MAX; i++) {
        if (a[i] > 0) {
            if (a[i] == 1) ans++;
            for (int j = 2; i * j <= MAX; j++) a[i * j] = 0;
        }
    }

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


Measured memory_bytes: 7452
n = int(input())
p = list(map(int,input().split()))
c = 0

for i in range(1,n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        c = c + 1

    if p[i-1] > p[i] and p[i] > p[i+1]:
        c = c + 1

print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int showAll(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
  return 0;
}

int souwa (int x) {
  if (x == 1) return 1;
  return x + souwa(x - 1);
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  int tmp;
  int index = 0;
  int max = 0;
  int first = 0;
  int sum = 0;
  rep (i, n) {
    cin >> tmp;
    v.push_back(tmp);
    sum += tmp;
    if (i == 0) first = tmp;
    if (i >= k) {
      sum = sum - first;
      first = v[i - k + 1];
    }
    if (i >= k - 1) {
      if (max < sum) {
        max = sum;
        index = i;
      }
    }
  }
  // cout << max << ": " <<  index << endl;

  double ans = 0;
  for (int i = index; i >= index - k + 1; i--) {
    ans += (double)souwa(v[i]) / v[i];
    // cout << v[i] << ": " << souwa(v[i]) << " / " << ans << endl;
  }
  printf("%.7f\n", ans);
  // showAll(rinsetu);

  return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>

template <class T>
using greater_queue=std::priority_queue<T, std::deque<T>, std::greater<T>>;

template <class Weight>
struct Edge {
  size_t src, dst;
  Weight cost;
  Edge(size_t src, size_t dst, Weight cost=1):
    src(src), dst(dst), cost(cost)
  {}
};

template <class Weight>
using Graph=std::vector<std::vector<Edge<Weight>>>;

template <class Weight>
constexpr Weight inf=(Weight(1)<<(8*sizeof (Weight)-3));

template <class Weight>
std::vector<Weight> dijkstra(const Graph<Weight> &g, size_t s) {
  std::vector<Weight> dist(g.size(), inf<Weight>);
  greater_queue<std::pair<Weight, size_t>> q;
  dist[s] = 0;
  q.emplace(0, s);
  while (!q.empty()) {
    auto p=q.top();
    q.pop();
    Weight w=p.first;
    size_t v=p.second;
    if (w > dist[v])
      continue;

    for (const Edge<Weight> &e: g[v]) {
      if (dist[e.dst] > w + e.cost) {
        dist[e.dst] = w + e.cost;
        q.emplace(dist[e.dst], e.dst);
      }
    }
  }
  return dist;
}

int main() {
  size_t N;
  scanf("%zu", &N);

  Graph<int> g(N);
  for (size_t i=1; i<N; ++i) {
    size_t a, b;
    scanf("%zu %zu", &a, &b);
    --a;
    --b;

    g[a].emplace_back(a, b);
    g[b].emplace_back(b, a);
  }

  std::vector<int> fennec=dijkstra(g, 0), snuke=dijkstra(g, N-1);
  int ff=0, ss=0;
  for (size_t i=0; i<N; ++i)
    ++(fennec[i]<=snuke[i]? ff:ss);

  printf("%s\n", ff>ss? "Fennec":"Snuke");
}


Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int a, b; cin >> a >> b;
	if(a == b) printf("Draw\n");
	else if(a != 1 && b != 1){
		if(a < b) printf("Bob\n");
		else printf("Alice\n");
	}else{
		if(a == 1)printf("Alice\n");
		else printf("Bob\n");
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val r = nextInt()
    println(when{
        r < 1200 -> "ABC"
        r < 2800 -> "ARC"
        else -> "AGC"
    })
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33512
// AOJ 1127: Building a Space Station
// 2017.9.19 bal4u@uu
// 2017.11.23

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define R 10
long long x[101], y[101], z[101], r[101];
char f[101];

char buf[100], *p;

long long dbl2int()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	if (*p == '.') p++;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n << R;
}

long long dist(long long dx, long long dy, long long dz)
{
	return (long long)sqrt((double)(dx*dx + dy*dy + dz*dz));
}

int main()
{
    int i, j, n, cnt, nx;
	long long ans, min, d;

    while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		memset(f, 0, n);
		for (i = 0; i < n; i++) {
			fgets(p=buf, 100, stdin);
			x[i] = dbl2int(), p++, y[i] = dbl2int(), p++, z[i] = dbl2int(), p++, r[i] = dbl2int();
		}
        ans = 0, f[1] = 1, cnt = 1;
        while (cnt < n) {
            for (nx = -1, min = 1LL<<60, i = 0; i < n; i++) {
                if (f[i] == 0) continue;
                for (j = 0; j < n; j++) {
                    if (f[j]) continue;
					d = dist(x[i]-x[j], y[i]-y[j], z[i]-z[j]) - (r[i]+r[j]);
					if (nx < 0 || d < min) min = d, nx = j;
                }
            }
            f[nx] = 1, cnt++; if (min > 0) ans += min;
        }
		ans = (ans+512) >> R;
        printf("%lld.%03lld\n", ans/1000, ans%1000);
    }
    return 0;
}

Measured memory_bytes: 1768
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<functional>
#include<set>
using namespace std;

#define INF 1<<21
#define DIV 1000000007
#define MAX 250000



int main(){
  char prime[MAX];
  prime[0] = 0;
  prime[1] = 0;
  memset(prime, 1, sizeof(prime));
  for (int i = 2; i*i <MAX ; i++) {
	if (prime[i]) {
	  for (int j = 2*i; j < MAX; j += i) {
		prime[j] = 0;
	  }
	}
  }
  int n;
  while (cin >> n, n) {
	int cnt = 0;
	for (int i = n + 1; i <= 2 * n; i++) {
	  if (prime[i])cnt++;
	}
	cout << cnt << endl;
  }
  return 0;
}

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

int main() {
    int N, L, a;
    cin >> N >> L;
    int A[N];
    for (int i=0; i<N; i++) A[i]=L+i;
    int sum=0;
    for (int i=0; i<N; i++){
        sum+=A[i];
    }
    int min_diff=100000000;
    for (int i=0; i<N; i++){
        if (min_diff > abs(sum-(sum-A[i]))){
            min_diff=abs(sum-(sum-A[i]));
            a=sum-A[i];
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *
sys.setrecursionlimit(2100)

def rec(sta, t):
    if memo[sta][t]!=-1:
        return memo[sta][t]
    
    if t==0:
        res = -10**18
        
        for i in range(sta, N):
            if i<N-1:
                res = max(res, rec(i+1, 1))
            else:
                if sta==0:
                    res = max(res, abs(a[N-1]-W))
                else:
                    res = max(res, abs(a[N-1]-a[sta-1]))
    else:
        res = 10**18
        
        for i in range(sta, N):
            if i<N-1:
                res = min(res, rec(i+1, 0))
            else:
                if sta==0:
                    res = min(res, abs(a[N-1]-Z))
                else:
                    res = min(res, abs(a[N-1]-a[sta-1]))
    
    memo[sta][t] = res
    
    return res

N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
memo = [[-1]*2 for _ in range(N)]
print(rec(0, 0))

Measured memory_bytes: 47708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int p;
    cin >> p;
    ll n = p-1, m = p, inv[n+1];
    rep2(i, 1, n+1){
        inv[i] = 1;
        ll e[30];
        e[0] = i;
        rep2(j, 1, 30) e[j] = (e[j-1]*e[j-1]) % m;
        ll k = m-2;
        int count = 0;
        while(k > 0){
            if(k % 2 == 1) inv[i] *= e[count], inv[i] %= m;
            k /= 2;
            count++;
        }
    }
    ll fac[p], invfac[p];
    fac[0] = 1, invfac[0] = 1;
    rep2(i, 1, p-1){
        fac[i] = (fac[i-1]*i)%p;
        invfac[i] = (invfac[i-1]*inv[i])%p;
    }
    ll a[p], b[p];
    fill_n(b, p, 0);
    rep(i, p){
        cin >> a[i];
        if(a[i] == 0) continue;
        b[0]++;
        ll ex[p];
        ex[0] = 1;
        rep2(j, 1, p-1) ex[j] = (ex[j-1]*(p-i))%p;
        rep(j, p){
            ll s = ex[p-1-j]*fac[p-1]*invfac[p-1-j]*invfac[j];
            s %= p;
            b[j] += p-s;
            b[j] %= p;
        }
    }
    rep(i, p) cout << b[i] << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,num=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int j=n-1;j>=1;j--){
    for(int i=n-1;i>=1;i--){
      if(a[i]<a[i-1]){
	int tmp=a[i];
	a[i]=a[i-1];
	a[i-1]=tmp;
	num++;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<a[i];
    if(i!=n-1)
      cout<<" ";
  }
  cout<<endl;
  cout<<num<<endl;
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc094/tasks/abc094_b

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

    int gates[105] = {};
    int A;
    for (int i = 0; i < M; i++) {
        cin >> A;
        gates[A] = 1;
    }

    int min = INF;

    int costA = 0;
    for (int j = X; j < N; j++) {
        costA += gates[j];
    }

    int costB = 0;
    for (int j = X; j > 0; j--) {
        costB += gates[j];
    }

    min = std::min(min, std::min(costA, costB));

    cout << min << "\n";

    return 0;
}


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

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

  int n;
  cin >> n;

  int ans = -1;
  for (int i = 1; i <= n; i++) {
    double x = floor(i * 1.08);
    if (x == n) {
      ans = i;
    }
  }

  if (ans < 0) {
    cout << ":(" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool prime[1000000];
int main(){
	for(int i = 2; i * i <= 1000000; i++){
		if(prime[i] == 0){
			for(int j = i; j <= 1000000; j+=i){
				prime[j] = 1;
			}
			prime[i] = 0;
		}
	}
	int n;
	while(cin >> n,n){
		int cnt = 0;
		for(int i = 2; i <= n/2; i++){
			if(prime[i])continue;
			else {
				if(!prime[n-i])cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int INF = 0x3f3f3f3f;
const int N=1e6+10;
map<int,int>q,q2;
int a[N];
string s[N];
int main() {
	int n,m;
	cin>>n>>m;
	ll ac=0,wa=0;
	for(int i=0;i<m;i++){
		cin>>a[i]>>s[i];
		if(s[i]=="AC"&&!q[a[i]]){
			ac++;
			q[a[i]]++;
			q2[a[i]]=i;
		}
	}
	for(int i=0;i<m;i++){
		if(s[i]=="WA"&&q[a[i]]&&i<q2[a[i]])wa++;
	}
	
	cout<<ac<<" "<<wa<<endl;
}


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 

template <class T>
void printArray(vector<T> arr) {for (T a: arr) cout << a << " ";cout << '\n';}
void printVerdict(bool verdict) {cout << (verdict ? "Yes": "No") << '\n';}
void printDecimal(double d) {printf("%.9f\n", d);}
bool inrange(int val, int start, int end) {return val >=start && val <= end;}
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	set<int> s;
	int a,b,c; cin >> a >> b >> c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	bool verdict = false;
	if (size(s) == 2) verdict = true;
	printVerdict(verdict);
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int x, a, b; cin >> x >> a >> b;
    cout << (x-a) % b << endl;
}

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

using namespace std;

int main(void){
	
	int A,B,C,D,E;
	int sum,i;
	vector<int> v;
	
	cin>>A>>B>>C>>D>>E;
	
	sum=sum+A+B+C+D+E;
	
	v.push_back(10-A%10);v.push_back(10-B%10);v.push_back(10-C%10);v.push_back(10-D%10);v.push_back(10-E%10);
	
	for(i=0;i<5;i++){
		if(v[i]==10)
			v[i]=0;
	}
	
	sort(v.begin(),v.end());
	
	for(i=0;i<4;i++){
		sum=sum+v[i];
	}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d\n",$h,$w);
for($i=0;$i<$h;$i++){
   $ar[$i]=fgets(STDIN); 
}
$dx = array(0,0,1,-1);
$dy=array(1,-1,0,0);
for($i=0;$i<$h;$i++){
    for($j=0;$j<$w;$j++){
        $ok=0;
        for($k=0;$k<4;$k++){
            $x=$i+$dx[$k];
            $y=$j+$dy[$k];
            if($x>=0&&$y>=0&&$x<$h&&$y<$w){
                if($ar[$x][$y]=='#'){
                  $ok=1;  
                }
            }
        }
        $flag[$i][$j]=$ok;
    }
}
$ng=0;
for($i=0;$i<$h;$i++){
    for($j=0;$j<$w;$j++){
        if($ar[$i][$j]=='#'&&$flag[$i][$j]==0){
            $ng=1;
        }
    }
}
if($ng){
    echo "No";
}
else{
    echo "Yes";
}
?>

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 998244353
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
ll power(ll a,ll b,ll m)
{
   ll ans=1;
   while(b>0)
   {
       if(b%2)
       {
           ans=(ans*a)%m;
       }
       a=(a*a)%m;
       b=b/2;
   }
   return ans;
}
ll inverse(ll a,ll m)
{
       return (power(a,m-2,m));
}

/// NCR
const int N = 300005;
ll fct[N];
ll invf[N];
ll dp[N];
ll C(ll n,ll r)
{
       if(r>n){return 0;}
       ll xx = (invf[r]*invf[n-r])%mod;
       xx *= fct[n];
       xx %= mod;
       return xx;
}
void initialize()
{
       fct[0] = 1;
       invf[0] = 1;
       fri(i,1,N){
              fct[i] = (i*fct[i-1])%mod;
              invf[i] = inverse(fct[i],mod);
       }
}
int main()
{
       initialize();
       ll n,m,k;
       cin>>n>>m>>k;
       dp[0] = (m*power(m-1,n-1,mod))%mod;
       fri(i,1,k+1)
       {
              dp[i] = (power(m,1,mod) * power(m-1,n-i-1,mod))%mod;
              dp[i] *= C(n-1,i);
       }
       ll ans = 0;
       fri(i,0,k+1){
              ans += dp[i];
              ans %= mod;
       }
       cout<<ans<<endl;
}


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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcode abc 176

int main(){
    
    ll x, y, m;

    cin>>x>>y>>m;

    ll col[x] = {0};
    ll row[y] = {0};

    set<string> s;

    ll a, b;

    for (int i = 0; i < m; ++i)
    {
        cin>>a>>b;

        s.insert(to_string(a)+":"+to_string(b));

        col[a-1]++;
        row[b-1]++; 
    }

    ll col_max = -1, col_x;
    ll row_max = -1, row_y;

    for (int i = 0; i < x; ++i)
    {
        if(col[i]>col_max){
            col_max = col[i];
            col_x = i+1;
        }
    }

    for (int i = 0; i < y; ++i)
    {
        if(row[i]>row_max){
            row_max = row[i];
            row_y = i+1;
        }
    }

    // string temp = to_string(col_x) + ":" + to_string(row_y);

    string temp;

    ll result = 0;

    if(col_max > row_max){

        temp = to_string(col_x) + ":";

        ll highest = 0;

        for (int i = 0; i < y; ++i)
        {
            string temp2 = temp + to_string(i+1);
            if(s.find(temp2)!=s.end()){
                highest = max(highest, row[i]-1);
            }
            else
                highest = max(highest, row[i]);
        }

        result = col_max + highest;
    }
    else{
        temp = ":" + to_string(row_y);

        ll highest = 0;

        for (int i = 0; i < x; ++i)
        {
            string temp2 = to_string(i+1) + temp;

            if(s.find(temp2)!=s.end()){
                highest = max(highest, col[i]-1);
            }
            else
                highest = max(highest, col[i]);
        }
        result = row_max + highest;
    }

    cout<<result<<endl;

}

Measured memory_bytes: 31764
C = []
for i in range(3):
  Cs = list(map(int, input().split()))
  C.append(Cs)
As = [0]*3
Bs = [0]*3
As[0] = 0
Bs[0] = C[0][0]-As[0]
for i in range(3):
  As[i] = C[i][0]-Bs[0]
for j in range(3):
  Bs[j] = C[0][j]-As[0]
ok = True
for i in range(3):
  for j in range(3):
    if C[i][j] != As[i]+Bs[j]:
      ok = False
if ok:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
    string s;
    getline(cin,s); //1行読み込む
        for(int i = 0; i < s.size(); i++){
            char c = s[i];
            if ('A' <= c && c <= 'Z') {
                //c = tolower(c);
                c = c + 32;
            }
            else if('a' <= c && c <= 'z'){
                c = c - 32;
            }
            cout << c;
        }
        cout << endl;
}


Measured memory_bytes: 3120