akhauriyash/Code-Regression huggingface dataset:
def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y, x%y)

N = int(input())
A = list(map(int, input().split()))

left_gcd = [A[0]]
a = A[0]
for i in range(1,N-1):
  a = gcd(a, A[i])
  left_gcd.append(a)

right_gcd = [A[N-1]]
b = A[N-1]
for k in range(N-2, 0, -1):
  b = gcd(b, A[k])
  right_gcd.append(b)

ans_gcd = [right_gcd[N-2], left_gcd[N-2]]

for p in range(N-2):
  ans_gcd.append(gcd(left_gcd[p], right_gcd[N-p-3]))

print(max(ans_gcd))

Measured memory_bytes: 14436
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

def valid(arr,l,cuts):
	#cuts = k
	#print(arr,l,cuts)
	for i in arr:
		cuts-=math.ceil((i)/l)-1;
	#print(cuts)
	return cuts>=0;

n , k = map(int , input().split())
arr = list(map(int , input().split()))
arr.sort()
lo = 1
hi = max(arr)
while lo != hi:
	mid = (hi + lo)//2
	#print(mid,hi,lo)
	if valid(arr , mid,k):
		#print("he")
		#break
		hi = mid
	else:
		lo = mid + 1
print(lo)












Measured memory_bytes: 104304
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LLI(): return [int(x) for x in sys.stdin.readlines()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from bisect import bisect_left

def main():
    N, Q = LI()
    XST = []
    for _ in range(N):
        s, t, x = LI()
        XST.append([x, s, t])
    XST.sort()
    D = LLI()
    ans = [-1] * Q
    nexts = [-1] * Q
    for x, s, t in XST:
        i = bisect_left(D, s - x)
        end = bisect_left(D, t - x)
        to = end
        while to < Q and nexts[to] != -1:
            to = nexts[to]
        while i < end:
            if nexts[i] == -1:
                ans[i] = x
                nexts[i] = to
                i += 1
            else:
                i = nexts[i]
    for y in ans:
        print(y)
    return

main()


Measured memory_bytes: 65564
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
#define iter(i, j) for(auto i = j.begin(); i != j.end(); ++i)
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end()  
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define file_io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define IMAX std::numeric_limits<int>::max()
#define IMIN std::numeric_limits<int>::min()
using namespace std;

int main()
{
    ll n, k; cin >> n >> k;
    vi p(n); rep(i, n) cin >> p[i];
    ll best = 0, prev;
    rep(i, k) best += p[i];
    prev = best;
    reps(i, k, n)
    {
        prev += p[i] - p[i - k];
        best = max(best, prev);
    }
    cout << setprecision(12) << (best + k) / ld(2);
    return 0;
}

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

using ull = unsigned long long;

int main(void) {
    int N;
    cin >> N;
    ull a=1, b=1;
    for(int i=0;i<N;i++) {
        ull _a, _b;
        cin >> _a >> _b;
        if(_a >= a && _b >= b) {
            a=_a, b=_b;
        }
        else {
            ull c = max(a/_a + ((a%_a)!=0), b/_b + ((b%_b)!=0));
            a=_a*c,b=_b*c;
        }
    }
    cout << a+b;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
	char k[9][5]={{'.',',','!','?',' '},
					{'a','b','c'},{'d','e','f'},
					{'g','h','i'},{'j','k','l'},
					{'m','n','o'},{'p','q','r','s'},
					{'t','u','v'},{'w','x','y','z'}};
	//0,6,8

	string s,out;
	int n;

	cin>>n;

	for(int i1=0;i1<n;i1++){
		cin>>s;
		out="";
		vector<int> v;
		for(int i2=0;i2<s.size();i2++){
			if(s[i2]=='0'){
				if(v.empty()){}
				else {
					if(v.back()==1){
						out+=k[v.back()-1][(v.size()-1)%5];
					}
					else if (v.back()==7 || v.back()==9){
						out+=k[v.back()-1][(v.size()-1)%4];
					}
					else{
						out+=k[v.back()-1][(v.size()-1)%3];
					}
					
				}
				v.clear();
			}
			else {
				if(!v.empty() && v.back()==s[i2]-48){
					v.push_back(s[i2]-48);
				}
				else {
					v.clear();
					v.push_back(s[i2]-48);
				}

			}
		}
		cout<<out<<endl;
	}

	return 0;
}

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

int main() {
  string A = "abcdefghijklmnopqrstuvwxyz";
  
  char s;
  cin >> s;
  
  for(int i=0; i< A.size(); i++){
    if(s != A.at(i)) continue;
  
    else{
      cout<<A.at(i+1)<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
q = 0
for i in range(n):
 for j in range(i, n):
  t = a[i]
  a[i] = a[j]
  a[j] = t
  f = 1  
  lst = - 1100
  for k in a:
   f &= k > lst
   lst = k
  q |= f
  t = a[i]
  a[i] = a[j]
  a[j] = t
print("YES" if q else "NO")


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N, K; cin >> N >> K;

	ll total = 0;

	FOR(b, 1, N + 1) {
		if (b <= K) continue;

		total += max(0, N % b - K + 1) + 1LL * N/b * (b - K);
		
		
	}

	if (K == 0) {
		print(1LL * N * N);
	} else {
		print(total);
	}
}

Measured memory_bytes: 256
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

    
def solve():
    l=li()
    s=set(l)
    print(len(s))
for _ in range(1):
    solve()
    


Measured memory_bytes: 9312
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += i;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21204
n = gets.to_s.to_i
s = gets.to_s.chomp
 
r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r * g * b
n.times do |i|
  t = 1
  while i + 2 * t < n
    j = i + t
    k = j + t
    ans -= 1 if s[i] != s[j] && s[j] != s[k] && s[k] != s[i]
    t += 1
  end
end

puts ans

Measured memory_bytes: 14284
s = input()
count = 0 
if (s == 'RRR'):
    count = 3
elif(s[:2] == 'RR' or s[1:] == 'RR'):
    count = 2
elif (s[0] == 'R' or s[1] == 'R' or s[2] == 'R'):
    count = 1
print(count)


Measured memory_bytes: 8932
import java.util.*;

import java.io.*;

public class Main {
	static String s1,s2;
	static int [][] memo;
	static StringBuilder ans;
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		s1=br.readLine();
		s2 = br.readLine();
		memo = new int[s1.length()][s2.length()];
		for(int i=0;i<s1.length();i++)Arrays.fill(memo[i], -1);
		dp(s1.length()-1,s2.length()-1);
		ans = new StringBuilder();
		trace(s1.length()-1 , s2.length()-1);
		System.out.println(ans.reverse());
	
	}
	public static int dp(int i,int j)
	{
		if(i==-1|| j==-1)return 0;
		if(memo[i][j]!=-1)return memo[i][j];
		if(s1.charAt(i)==s2.charAt(j))return memo[i][j] = 1+dp(i-1,j-1);
		return memo[i][j]=Math.max(dp(i-1,j),dp(i,j-1));
	}
	
	public static void trace(int i , int j)
	{
		if(i==-1 || j==-1)return;
		if(s1.charAt(i)==s2.charAt(j)) {
			ans.append(s1.charAt(i));
			trace(i-1,j-1);
		}
		else
		{
			if(i>0 && j>0)
			{
				if(memo[i-1][j]>=memo[i][j-1])trace(i-1,j);
				else trace(i,j-1);
			}
			else if(i>0)trace(i-1,j);
			else if(j>0)trace(i,j-1);
			
		}
	}
	
	
	
	

}


Measured memory_bytes: 84692
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int a[3][100010];
int dp[3][100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) rep(j, 3) cin >> a[j][i];
    rep(j, 3) dp[j][0] = a[j][0];
    rep(i, N - 1) {
        rep(j, 3) {
            dp[j][i + 1] = a[j][i + 1] + max(dp[(j + 1) % 3][i], dp[(j + 2) % 3][i]);
        }
    }
    cout << max({dp[0][N - 1], dp[1][N - 1], dp[2][N - 1]}) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <deque>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int visited[102][102][1<<5];
int co[102][102];
char f[102][102];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

class state{
	public:
	int x,y,co,st;
	
	state(){}
	
	state(int _y, int _x, int _co, int _state){
		x = _x;
		y = _y;
		co = _co;
		st = _state;
	}
};

int main(){
	int w,h;
	int sx, sy, gx, gy;
	int m=0;
	char c;
	memset(co, -1 , sizeof(co));
	fill((int *)visited, (int *)visited+102*102*(1<<5), 1 << 29);
	cin >> w >> h;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			co[i][j] = 1;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin >> f[i][j];
			if(f[i][j] == '#'){
				for(int p=-2;p<=2;p++){
					for(int q=-2;q<=2;q++){
						if(0 <= i+p && i+p <= h && 0 <= j+q && j+q <= w){
							if((p == 0 && q == 0) || co[i+p][j+q] == -1){
								co[i+p][j+q] = -1;
							}else if(max(abs(p), abs(q)) == 2){
								co[i+p][j+q] = max(co[i+p][j+q],2);
							}else{
								co[i+p][j+q] = max(co[i+p][j+q],3);
							}
						}
					}
				}
			}else if(f[i][j] == 'S'){
				sy = i;
				sx = j;
			}else if(f[i][j] == 'G'){
				gy = i;
				gx = j;
			}else if(f[i][j] == 'M'){
				f[i][j] = m + '0';
				m++;
			}
		}
	}
	/*
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cout << f[i][j];
		}
		cout << endl;
	}
	cout << endl;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cout << co[i][j];
		}
		cout << endl;
	}
	*/
	deque<state> q;
	state st;
	int tx,ty,tco,tstate,nx,ny,nstate;
	q.push_back(state(sy,sx,0,0));
	visited[sy][sx][0] = 0;
	while(!q.empty()){
		st = q.front();
		q.pop_front();
		tx = st.x;
		ty = st.y;
		tco = st.co;
		tstate = st.st;
		//printf("now (%d,%d) cost = %d, state = %d\n",ty,tx,tco,tstate);
		for(int i=0;i<4;i++){
			nx = tx + dx[i];
			ny = ty + dy[i];
			if(co[ny][nx] == -1) continue; //入れない場合
			if('0' <= f[ny][nx] && f[ny][nx] <= '9'){ //まきものの場合
				nstate = tstate | (1 << (f[ny][nx] - '0'));
				if(visited[ny][nx][nstate] > tco + co[ty][tx]){
					visited[ny][nx][nstate] = tco + co[ty][tx];
					q.push_back(state(ny,nx,tco+co[ty][tx],nstate));
				}
			}else{
				if(visited[ny][nx][tstate] > tco + co[ty][tx]){
					visited[ny][nx][tstate] = tco + co[ty][tx];
					q.push_back(state(ny,nx,tco+co[ty][tx],tstate));
				}
			}
		}
	}
	cout << visited[gy][gx][(1 << m) - 1] << endl;
}

Measured memory_bytes: 7300
#include <iostream>

int main() {
  int A, B, AB;  // ピザの値段
  std::cin >> A >> B >> AB;

  int X, Y;  //ピザの枚数
  std::cin >> X >> Y;

  int k = X <= Y ? Y : X;

  int ans = 0;

  for (int l = 0; l <= k; l++) {
    int i = X - l;
    i = i < 0 ? 0 : i;

    int j = Y - l;
    j = j < 0 ? 0 : j;

    int tmp = A * i + B * j + AB * l * 2;

    ans = l == 0 ? tmp : tmp <= ans ? tmp : ans;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
	FastScanner sc = new FastScanner();
        
    	int N = sc.nextInt();
    	long X = sc.nextLong();
    	
    	long[] total = new long[N+1];
    	
    	total[0] = 1;
    	for(int i=1; i<=N; i++){
    		total[i] = 2*total[i-1]+3;
    	}
    	
    	long[] pati = new long[N+1];
    	pati[0] = 1;
    	for(int i=1; i<=N; i++){
    		pati[i] = 2*pati[i-1]+1;
    	}
    	
    	System.out.println(solve(N,X,total,pati));
    }
    
    static long solve(int N, long X, long[] total, long[] pati){
    	if(N==0){
    		if(X==1){
    			return 1;
    		}
    		else{
    			return 0;
    		}
    	}
    	
    	long dif = X-total[N-1];
    	
    	if(X == total[N]){
    		return pati[N];
    	}
    	else if(dif > 2){
    		return pati[N-1] + 1 + solve(N-1,X-total[N-1]-2,total,pati);
    	}
    	else if(dif == 2){
    		return pati[N-1] + 1;
    	}
    	else{
    		return solve(N-1,X-1,total,pati);
    	}
    }
    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22996
import  java.util.Scanner;
 
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ans = Integer.MAX_VALUE;
		for(long i = 1; i * i <= N; i++) {
			if(N % i == 0) {
				ans = Math.min(ans, Math.max(Long.toString(i).length(), Long.toString(N / i).length()));
			}
		}
		System.out.println(ans);
	}
}

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i%k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int a, b;
  REP(i, 7){
    cin >>a >>b;
    cout <<abs(a - b) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import Data.Fixed (Micro)
import Control.Monad (when)

judge :: [Micro] -> String 
judge xs@[x1,y1,x2,y2,x3,y3,x4,y4]
  | (y1 - y2) == (y3 - y4) && (y1 - y2) == 0 = "YES"
  | (y1 - y2) == 0         || (y3 - y4) == 0 = "NO"   
  | (x1 - x2) / (y1 - y2) == (x3 - x4) / (y3 - y4) = "YES"
  | otherwise = "NO"

main = do
  s' <- getContents
  let l = read $ head $ words s'
  let s = map (map (read :: String -> Micro))
               $ map words $ tail $ filter (/="") $ lines s'
  when (l <= (length s')) $ putStr $ unlines $ map judge s

Measured memory_bytes: 4404
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll C[200010];
    rep(i,0,N) cin >> C[i];
    sort(C, C+N);
    Combination cb(200010);
    ll ans = 0;
    if(N == 1){
        print(2 * C[0] % MOD);
        return 0;
    }
    ll v1 = 0, diff_all = 0;

    rep(i,1,N+1){ //i個異なる
        ll max_val = i * cb.nck(N-1, i-1) % MOD;
        ll min_val = cb.nck(N-1, i-1);
        ll diff = (max_val - min_val + MOD) % MOD * cb.power(N-1, MOD-2) % MOD;
        v1 += max_val;
        v1 %= MOD;
        diff_all += diff;
        diff_all %= MOD;
    }
    ll cur = v1;
    rep(i,0,N){
        ans += cur * C[i] % MOD;
        ans %= MOD;
        cur = (cur - diff_all + MOD) % MOD;
    }
    ans *= cb.power(2, N);
    ans %= MOD;
    print(ans);

    
    

}

Measured memory_bytes: 6512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int Q = sc.nextInt();
        int[] S = new int[N];
        int[] T = new int[N];
        int[] X = new int[N];
        for (int i = 0; i < N; ++i) {
            S[i] = sc.nextInt();
            T[i] = sc.nextInt();
            X[i] = sc.nextInt();
        }
        int[] D = new int[Q];
        for (int i = 0; i < D.length; ++i) {
            D[i] = sc.nextInt();
        }

        System.out.println(solve(S, T, X, D));

        sc.close();
    }

    static String solve(int[] S, int[] T, int[] X, int[] D) {
        @SuppressWarnings("unchecked")
        List<Integer>[] beginLists = new List[D.length];
        for (int i = 0; i < beginLists.length; ++i) {
            beginLists[i] = new ArrayList<>();
        }

        @SuppressWarnings("unchecked")
        List<Integer>[] endLists = new List[D.length];
        for (int i = 0; i < endLists.length; ++i) {
            endLists[i] = new ArrayList<>();
        }

        for (int i = 0; i < S.length; ++i) {
            int leftIndex = findLeftIndex(D, S[i] - X[i]);
            int rightIndex = findRightIndex(D, T[i] - X[i]);

            if (leftIndex <= rightIndex) {
                beginLists[leftIndex].add(X[i]);
                endLists[rightIndex].add(X[i]);
            }
        }

        int[] result = new int[D.length];
        SortedSet<Integer> blocked = new TreeSet<>();
        for (int i = 0; i < result.length; ++i) {
            blocked.addAll(beginLists[i]);

            result[i] = blocked.isEmpty() ? -1 : blocked.first();

            blocked.removeAll(endLists[i]);
        }

        return Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining("\n"));
    }

    static int findLeftIndex(int[] D, int start) {
        int result = D.length;
        int lower = 0;
        int upper = D.length - 1;
        while (lower <= upper) {
            int middle = (lower + upper) / 2;
            if (D[middle] >= start) {
                result = middle;
                upper = middle - 1;
            } else {
                lower = middle + 1;
            }
        }

        return result;
    }

    static int findRightIndex(int[] D, int end) {
        int result = -1;
        int lower = 0;
        int upper = D.length - 1;
        while (lower <= upper) {
            int middle = (lower + upper) / 2;
            if (D[middle] < end) {
                result = middle;
                lower = middle + 1;
            } else {
                upper = middle - 1;
            }
        }

        return result;
    }
}

Measured memory_bytes: 99528
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    
    int n,m;

    cin>>n>>m;

    int ar[n+1];

    int sum = 0;

    repa(i,1,n)
    {
        cin>>ar[i];
        sum+=ar[i];
        ar[i]*=(4*m);
    }

    int cnt =  0;

    repa(i,1,n)
        cnt+=(ar[i]>=sum);
    
    if (cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>

const int N = 2e5 + 1;

template<typename T>
struct Vec {
    T x, y;
    Vec (T x, T y) : x(x), y(y) {}
    
    Vec<T> operator-(const Vec<T> &o) const { return Vec<T>(x - o.x, y - o.y); }
    T operator%(const Vec<T> &o) const { return x * o.y - y * o.x; }
    bool operator==(const Vec<T> &o) const { return x == o.x && y == o.y; }
    bool operator!=(const Vec<T> &o) const { return x != o.x || y != o.y; }
};

bool vectorLT(const Vec<ll>& lhs, const Vec<ll>& rhs) {
    if (lhs.x != rhs.x)
        return lhs.x < rhs.x;
    return lhs.y < rhs.y;
}
struct ConvexHull {
    void removeDupes(vector<Vec<ll>> &pts) {
        sort(pts.begin(), pts.end(), vectorLT);
        pts.erase(unique(pts.begin(), pts.end()), pts.end());
    }
    
    bool right(Vec<ll> a, Vec<ll> b, Vec<ll> c) {
        return (b - a) % (c - a) > 0;
    }

    vector<Vec<ll>> getHull(vector<Vec<ll>> pts) {
        sort(pts.begin(), pts.end(), vectorLT);
        if (pts.size() < 3) return pts;
        int n = pts.size(), j = 2, k = 2;
        vector<Vec<ll>> lo(n, Vec<ll>(0, 0));
        vector<Vec<ll>> hi(n, Vec<ll>(0, 0));
        lo[0] = pts[0]; lo[1] = pts[1];
        for (int i = 2; i < n; i++) {
            Vec<ll> p = pts[i];
            while (j > 1 && !right(lo[j - 2], lo[j - 1], p)) j--;
            lo[j++] = p;
        }
        hi[0] = pts[n - 1], hi[1] = pts[n - 2];
        for (int i = n - 3; i >= 0; i--) {
            Vec<ll> p = pts[i];
            while (k > 1 && !right(hi[k - 2], hi[k - 1], p)) k--;
            hi[k++] = p;
        }
        vector<Vec<ll>> ans;
        ans.reserve(j + k - 2);
        for (int i = 0; i < k; i++) ans.push_back(hi[i]);
        for (int i = 1; i < j - 1; i++) ans.push_back(lo[i]);
        return ans;
    }
};

void solve() {
    int n;
    cin >> n;

    vector<Vec<ll>> pts;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        pts.emplace_back(x, y);
    }

    ConvexHull ch;
    ch.removeDupes(pts);
    vector<Vec<ll>> hull = ch.getHull(pts);
    int m = SZ(hull);

    auto dist = [&](Vec<ll> u, Vec<ll> v) {
        return abs(u.x - v.x) + abs(u.y - v.y);
    };

    ll ans = 0;
    for (int i = 0, j = 1 % m; i < m; i++) {
        ll cur = dist(hull[i], hull[j]);
        while (i != j && dist(hull[i], hull[(j + 1) % m]) >= cur) {
            ans = max(ans, cur);
            j = (j + 1) % m;
            cur = dist(hull[i], hull[j]);
        }
        ans = max(ans, cur);
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;

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

    sort(a.rbegin(), a.rend());

    ll a1 = 0;
    ll a2 = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == a[i+1]) {
            if (a1 == 0) {
                a1 = a[i];
                i++;
            } else {
                a2 = a[i];
                break;
            }
        }
    }

    cout << a1 * a2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;


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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
while(1){
int n,x;
cin>>n>>x;
if(n == 0 && x == 0) break;
int ans =0;
for(int a=1;a<= n;a++)
for(int b=a+1;b<=n;b++)
for(int c=b+1;c<=n;c++){
if(a+b+c != x) continue;
ans++;
}
cout<<ans<<endl;
}
return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

int main(){
    fastIO;
    int n,k;
    cin >> n >> k;
    int in[n];
    for(int i=0;i<n;i++){
        cin >> in[i];
    }
    for(int i=k;i<n;i++){
        if(in[i]>in[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 4396
//  LINK ZADATKA: http://tenka1-2017.contest.atcoder.jp/tasks/tenka1_2017_c

#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9

ll n; ll h, k, w; ll brojnik, nazivnik;
int main(){
	
	slld(n);
	//i = h, j = k
	FOR(i, 1, 3500){
		FOR(j, 1, 3500){
			brojnik = ll(n*(ll)i*(ll)j);
			nazivnik = (4*(ll)i*(ll)j) - (n*(ll)j) - (n*(ll)i);
			//printf("%d %d", brojnik, nazivnik);
			if(nazivnik > 0 && brojnik > 0){
				if((brojnik % nazivnik) == 0){
					//printf("%I64d %I64d\n", brojnik, nazivnik);
					h = i; k = j; w = (brojnik / nazivnik);
					printf("%lld %lld %lld\n", k, h, w);
					return 0;
				}
			}
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> dp(100001,-1);

int back(vector<int> &N, int index){
	if(index+2==N.size()){
		return abs(N[index]-N[index+1]);
	}
	if(index+1==N.size()){
		return 0;
	}
	if(dp[N.size()-index]!=-1)return dp[N.size()-index];
	int a = abs(N[index]-N[index+1]) + back(N,index+1);
	int b = abs(N[index]-N[index+2]) + back(N,index+2);
	
	dp[N.size()-index] = min(a,b);
	return dp[N.size()-index];
}

int main(){
//	10 30 40 20
	int n;
	cin>>n;
	vector<int> N(n);
	for(int i=0;i<n;i++){
		cin>>N[i];
	}
	dp[0]=0;
	dp[1]=abs(N[0]-N[1]);

	cout<<back(N,0);	
}

Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
const long long MOD = (long long)1e9 + 7;

long long modpow(long long x, long long y){
	if(y == 0) return 1;
	if(y % 2 == 0){
		long long t = modpow(x, y / 2);
		return t * t % MOD;
	}else{
		long long t = modpow(x, (y - 1) / 2);
		return x * (t * t % MOD) % MOD;
	}
}
 
long long comb(long long x, long long y){
	y = min(x - y, y);
	long long resmul = 1, resdiv = 1;
	for(int i = 0; i < y; i++){
		resmul = resmul * (x - i) % MOD;
		resdiv = resdiv * (y - i) % MOD;
	}
	return resmul * modpow(resdiv, MOD - 2) % MOD;
}
 
int main(){
	long long n, m, ans = 1;
	cin >> n >> m;
	long long t = m;
	for(int i = 2; i * i <= t; i++){
		if(t % i == 0){
			long long cnt = 0;
			while(t % i == 0){
				t /= i;
				cnt++;
			}
			ans = (ans * comb(n + cnt - 1, cnt)) % MOD;
            if(t == 1) break;
		}
	}
    if(t > 1) ans = (ans * n) % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// atcoder/abc128/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, p;
  while (cin >> a >> p) {
    cout << (p + a * 3) / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int res[100]={0};
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		res[a]++;
		res[b]++;
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",res[i]);
	}
} 

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

alias A = Tuple!(int, "i", int, "j");
alias LR = Tuple!(int, "i", int, "l", int, "r", long, "ret");

int H, W, D, Q;
A[300*300+1] AS;
LR[10^^5] QS;

void main()
{
    auto hwd = readln.split.to!(int[]);
    H = hwd[0];
    W = hwd[1];
    D = hwd[2];

    foreach (j; 0..H)
        foreach (i, e; readln.split.to!(int[]))
            AS[e] = A(i.to!int, j);

    Q = readln.chomp.to!int;
    foreach (i; 0..Q) {
        auto lr = readln.split.to!(int[]);
        QS[i] = LR(i, lr[0], lr[1], 0);
    }
    sort!"a.l == b.l ? a.r < b.r : a.l < b.l"(QS[0..Q]);
    LR[][] qss;
    int ll;
    auto ap = appender!(LR[]);
    foreach (q; QS[0..Q]) {
        if (q.l != ll) {
            ll = q.l;
            qss ~= ap.data;
            ap = appender!(LR[]);
        }
        ap.put(q);
    }
    qss ~= ap.data;
    qss = qss[1..$];

    auto ret = appender!(LR[]);
    foreach (qs; qss) {
        auto L = qs[0].l;
        auto x = L;
        long d;
        while (!qs.empty) {
            if (qs[0].r == x) {
                auto q = qs[0];
                q.ret = d;
                ret.put(q);
                qs = qs[1..$];
            } else {
                auto a = AS[x];
                x += D;
                auto ad = AS[x];
                d += abs(a.i - ad.i) + abs(a.j - ad.j);
            }
        }
    }
    auto ans = ret.data;
    sort!"a.i < b.i"(ans);
    foreach (q; ans) writeln(q.ret);
}

Measured memory_bytes: 25596
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int N,L;
    cin>>N>>L;
    vector<string> str(N);
    for(int i=0;i<N;i++){
        cin>>str[i];
    }
    sort(str.begin(),str.end());
    for(int i=0;i<N;i++){
        cout<<str[i];
    }

    
    
    return 0;
}

Measured memory_bytes: 256
def hantei(A,B,C,R=0):
    p,q = sorted([A,B,C])[:2]
    if p**2 + q**2 < 4 * R**2:
        print 'OK'
    else:
        print 'NA'

while True:
    try:
        A,B,C = map(int,raw_input().split())
        if (A,B,C) == (0,0,0):
            break
    except EOFError:
        break

    for k in range(int(raw_input())):
        hantei(A,B,C,int(raw_input()))

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<ll> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    ll minusAndmax = -MOD;
    ll plusAndmin = MOD;

    int minusCnt = 0;
    rep(i, n){
        if (a[i] < 0){
            minusAndmax = max(minusAndmax, a[i]);
            minusCnt++;
        } else {
            plusAndmin = min(plusAndmin, a[i]);
        }
    }
    ll ans = 0;
    rep(i, n) ans+= abs(a[i]);
    if (minusCnt%2 != 0){
        if (abs(minusAndmax) > plusAndmin){
            ans -= plusAndmin*2;
        } else {
            ans -= abs(minusAndmax)*2;
        }
    }

    cout << ans << endl;

}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define pque priority_queue<long long int >
#define pquem priority_queue<long long int ,vector<long long int>,greater<long long int> >
#define setbits(x) __builtin_popcountll(x)
#define mod 1000000007
#define inf 1e18 
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int ab[1000001];
void sieve()
{
	ab[1]=1;
	for(int i=2;i<1000001;i++)
	ab[i]=i;
	for(int i=4;i<1000001;i+=2)
	ab[i]=2;
    for(int i=3;i*i<1000001;i++)
    {
        if(ab[i]==i)
        {
            for(int j=i*i;j<1000001;j+=i)
            {
            	if(ab[j]==j)
                ab[j]=i;
            }
        }
    }
}
ll power(ll a,ll b)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
		ans*=a;
		b/=2;
		a*=a;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a,b,n;
	cin>>a>>b>>n;
	ll ans;
	if(n<b)
	ans=floor((a*n)/b);
	else
	ans=floor((a*(b-1))/b);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define getcx getchar_unlocked
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int main() {

	LL n, arr[2*MAX], i, sum = 0, ans = 0;
	
	cin>>n;
	for(i = 0 ; i < n ;i++) {
		cin>>arr[i];
		sum = (sum + arr[i]);
	}	

	for(i = 0; i < n-1; i++) {
		sum = sum - arr[i];
		ans = (ans + (arr[i] * (sum %MOD))% MOD)%MOD;
	}

	cout<<ans<<en;

	return 0;
}

Measured memory_bytes: 5188
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,t=0,a=0,b=0,c=0;
    string s;
    lli i,j;
    cin>>n;
    rep(i,0,n){
        cin>>s;
        rep(j,0,s.size()-2){
            if((s[j]=='A')&&(s[j+1]=='B')){
                t++;
            }
        }
        if(s[0]=='B'){
            if(s[s.size()-1]=='A'){
                c++;
            }
            else{
                b++;
            }
        }
        else{
            if(s[s.size()-1]=='A'){
                a++;
            }
        }
    }
    if(c>0){
        if(c>1){
            t+=c-1;
        }
        if(a>0){
            a--;
            t++;
        }
        if(b>0){
            b--;
            t++;
        }
    }
    t+=min(a,b);
    cout<<t<<endl;
}


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

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a != c) {
    cout << "Yes" << endl;
    return 0;
  }
  if (a == c && a != b) {
    cout << "Yes" << endl;
    return 0;
  }

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

  return 0;
}

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

const string base36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 

int main() {
  for (int n, m, q; cin >> n >> m >> q, n;) {
    vector<vector<int>> s(q, vector<int>(n, 0));
    vector<vector<int>> b(q, vector<int>(m, 0));
    {
      vector<string> st(q), bt(q);
      REP(i, q) {
        cin >> st[i] >> bt[i];
      }
      REP(i, q) {
        REP(j, n) s[i][j] = (st[i][j] == '1');
        REP(j, m) b[i][j] = (bt[i][j] == '1');
      }
    }
    vector<string> cs(q);
    vector<string> cb(q);
    REP(i, q) {
      REP(j, n) {
        if (i > 0) s[i][j] ^= s[i - 1][j];
        cs[i] += '0' + s[i][j];
      }
      REP(j, m) {
        cb[i] += '0' + b[i][j];
      }
    }
    map<string, int> mp;
    REP(i, n) {
      string t;
      REP(j, q) t += cs[j][i];
      if (mp.find(t) == mp.end()) {
        mp[t] = i;
      } else {
        mp[t] = -i;
      }
    }
    string ans;
    REP(i, m) {
      string t;
      REP(j, q) t += cb[j][i]; 
      if (mp[t] >= 0) {
        ans += base36[mp[t]];
      } else {
        ans += '?';
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 8140
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll x;
	cin>>x;
	ll ans=(x/500)*1000;
	x%=500;
	ans+=(x/5)*5;
	cout<<ans<<"\n";
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3576
#include <iostream>

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

	if (N == 1 || M == 1) {
		if (N == 1 && M == 1) {
			std::cout << 1 << std::endl;
			return 0;
		}
		int notOne;
		if (N == 1) {
			notOne = M;
		} else {
			notOne = N;
		}
		std::cout << notOne - 2 << std::endl;
		return 0;
	}

	if (N == 2 || M == 2) {
		std::cout << 0 << std::endl;
		return 0;
	}

	std::cout << (long long)(N - 2) * (M - 2) << std::endl;

	return 0;
}

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

int main(void){
	int a,b;
	cin >> a >> b;

	if(a==1) a+=13;
	if(b==1) b+=13;

	if(a>b)
		cout << "Alice" << endl;
	else if(a<b)
		cout << "Bob" << endl;
	else
		cout << "Draw" << endl;

	return 0;

}


Measured memory_bytes: 256