akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  int a,b;
  cin>>a>>b;
  int c=a*(a-1)/2+b*(b-1)/2;
  cout<<c;
}

Measured memory_bytes: 256
import sys
from itertools import permutations
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n = int(readline())
p = tuple(map(int, readline().split()))
q = tuple(map(int, readline().split()))

l = list(range(1, n+1))
l_ = list(permutations(l))

print(abs(l_.index(q) - l_.index(p)))




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

struct Stone
{
  int height;
  int shortestPath;
};

int main()
{
  int nbStones;
  cin >> nbStones;
  vector<Stone> stones;
  for (int i = 0; i < nbStones; i++)
  {
    int height;
    cin >> height;
    stones.push_back({height, 0});
  }
  stones[nbStones - 2].shortestPath = abs(stones[nbStones - 1].height - stones[nbStones - 2].height);
  for (int j = nbStones - 3; j >= 0; j--)
    stones[j].shortestPath = min((stones[j+1].shortestPath + abs(stones[j].height - stones[j+1].height)),
				 (stones[j+2].shortestPath + abs(stones[j].height - stones[j+2].height)));
  cout << stones[0].shortestPath << '\n';
}


Measured memory_bytes: 1400
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
	
		int x = stdIn.nextInt();
		
		int n = stdIn.nextInt();
		
		if(n == 0) {
			System.out.println(x);
			return;
		}
		
		
		
		int[] p = new int[n];
		
		boolean[] num = new boolean[101];
		
		for(int i = 0; i < n; i++) {
			p[i] = stdIn.nextInt();
			num[p[i]] = true;
		}
		
		Arrays.parallelSort(p);	
		
		int a = Integer.MAX_VALUE;
		int b = Integer.MAX_VALUE;
		
		for(int i = x; i >= 0; i--) {
			if(!num[i]) {
				a = i;
				break;
			}
		}
		
		for(int i = x; i <= 100; i++) {
			if(!num[i]) {
				b = i;
				break;
			}
		}
		
		if(b == Integer.MAX_VALUE) {
			b = 101;
		}
		
		
		//int ans = Math.min(Math.abs(x-a), Math.abs(x-b));
		
		if(Math.abs(x-a) <= Math.abs(x-b)) {
			System.out.println(a);
		}else {
			System.out.println(b);
		}
		
		
	}
}


Measured memory_bytes: 36024
#include <iostream>

int main()
{
    long long A;
    double B;
    std::cin >> A >> B;

    long long tmpB = (B*100) + 0.5; // 2進数だと循環してしまう場合がある 
                                    // 4.1 が4.09...となってしまう 
                                    // キャスト時に四捨五入されるのを利用して 
                                    // 4.09 + 0.05 = 4.13 → (int)4.1 
    long long ans = A * tmpB;
    ans /= 100;

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

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


int main(){

    int a, b; cin >> a >> b;
    if(a > 9 || b > 9){
        cout << -1; 
        return 0;
    }else{
        cout << a * b;
    }
}

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int[] A = new int[3];
		for (int i = 0; i < 3; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		int ans = A[1] - A[0];
		ans += A[2] - A[1];
		System.out.println(ans);
	}



	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

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: 21204
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define int long long
#define mkpr make_pair
#define REP(i,a,b) for (i = a; i <= b; i++)
#define RREP(i,a,b) for (int i = a; i >= b; i--)

typedef pair<int, int> pii;
typedef map<int, int> mpii;
typedef unordered_map<int, int> umpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
#define ff first
#define ss second
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define precise(x) cout<<fixed<<setprecision(9)<<x<<endl
#define mod 1000000007
#define MAX 200010
#define INF (long long) 4e18
#define endl "\n"

void in() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	in();
	int n, d;
	cin >> n >> d;
	int cnt = 0;
	while (n --) {
		int x, y;
		cin >> x >> y;
		double ans = sqrt(x * x + y * y);

		if (floor(ans) == d && abs(ans - floor(ans)) > 0)
			continue;
		if (floor(ans) <= d)
			cnt++;

	}
	cout << cnt << endl;
}

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


int main(){
	int a,b;
	while(cin>>a>>b,a|b){
		int c[10]={},hit=0,blow=0;
		for(int i=0;i<4;i++){
			if(a%10==b%10)hit++;
			c[a%10] |= 1;
			c[b%10] |= 2;
			a/=10;
			b/=10;
		}
		for(int i=0;i<10;i++){
			if(c[i]==3)blow++;
		}
		blow -= hit;
		cout<<hit<<' '<<blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    Int A, B; cin >> A >> B;
    Int ans = A*B/2;
    if (A*B%2) ans++;
    if (A == 1 || B == 1) {
        ans = 1;
    }
    cout << ans << endl;
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	if ((b-a)%2==0) {
		cout << "Alice" << "\n";
		return 0;
	}
	cout << "Borys" << "\n";
	return 0;
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define fin(ds) for (auto &v : ds) cin >> v;
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define nl '\n'

typedef long long ll;

signed main() { _
    int n; cin >> n;
    set<string> colors;
    forn(i, n) {
        string s; cin >> s;
        colors.insert(s);
    }
    if (colors.count("Y")) {
        cout << "Four" << nl;
    } else {
        cout << "Three" << nl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char a[110][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), res(101010);
	res[0] = 3;
	ll ans = 1;
	rep(i, n) {
		cin >> a[i];
		ans *= (res[a[i]] - res[a[i] + 1]);
		ans %= MOD;
		res[a[i] + 1]++;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int A[N + 2];
    A[0] = 0;
    A[N + 1] = 0;
    rep(i, N) cin >> A[i + 1];
    int dis[N];
    int total = 0;
    rep(i, N + 1)
    {
        total += abs(A[i] - A[i + 1]);
        //        cout << A[i] << " " << A[i + 1] << endl;
        //        cout << total << endl;
    }
    //   cout << total << endl;
    for (int i = 1; i < N + 1; i++)
    {
        int tmp1 = abs(A[i] - A[i - 1]);
        int tmp2 = abs(A[i] - A[i + 1]);
        int tmp3 = abs(A[i - 1] - A[i + 1]);
        //       cout << tmp1 << " " << tmp2 << " " << tmp3 << endl;
        dis[i] = tmp3 - tmp1 - tmp2;
    }
    for (int i = 1; i < N + 1; i++)
    {
        cout << total + dis[i] << endl;
    }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main(){
	int n,x;
	cin>>n>>x;
	for(int i=0;i<n;i++)cin>>a[i];
	int cnt=0;
	int ans=1;
	for(int i=0;i<n;i++){
		cnt=cnt+a[i];
		if(cnt<=x)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli h,w,n;
	cin>>h>>w>>n;
	lli sr,sc;
	cin>>sr>>sc;

	sr--,sc--;

	string s,t;
	cin>>s>>t;

	//左右
	lli nowL = -1,nowR = w;
	for(lli i=s.size()-1;i>=0;i--){
		//青木君落とされないようにするぞ
		if(t.at(i)=='L')nowR = min(nowR+1,w);
		if(t.at(i)=='R')nowL = max(nowL-1,-1LL);

		//高橋君落としに行くぞ
		if(s.at(i)=='L')nowL = min(nowL+1,h);
		if(s.at(i)=='R')nowR = max(nowR-1,-1LL);

		if(nowL+1>=nowR){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	if(sc<=nowL || nowR<=sc){
		cout<<"NO"<<endl;
		return 0;
	}

	nowL = -1,nowR = h;
	for(lli i=s.size()-1;i>=0;i--){
		//青木君落とされないようにするぞ

		if(t.at(i)=='U')nowR = min(nowR+1,h);
		if(t.at(i)=='D')nowL = max(nowL-1,-1LL);

		//高橋君落としに行くぞ
		if(s.at(i)=='U')nowL = min(nowL+1,h);
		if(s.at(i)=='D')nowR = max(nowR-1,-1LL);

		if(nowL+1>=nowR){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	if(sr<=nowL || nowR<=sr){
		cout<<"NO"<<endl;
		return 0;
	}

	cout<<"YES"<<endl;


	return 0;
}

Measured memory_bytes: 776
n,k = map(int,input().split())
alist = list(map(int,input().split()))

town_loop = [1]
used = [-1] * n

for i in range(k):
    next_town = alist[town_loop[i]-1]

    if used[next_town-1] == -1:
        town_loop.append(next_town)
        used[next_town-1] = 1
    else:
        break

loop_start = town_loop.index(next_town)
if len(town_loop) == k+1:
    print(town_loop[k])
else:
    o = len(town_loop) - loop_start
    print(town_loop[((k-loop_start) % o) + loop_start])


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

long long int dp[20001][256] = {};

int main() {

  while( true ) {

    long long int n, m;
    cin >> n >> m;
    if ( n == 0 ) break;

    vector< long long int > c;

    for ( long long int i = 0; i < m; i++ ) {

      long long int in;
      cin >> in;
      c.push_back( in );

    }

    for ( long long int i = 0; i <= n; i++ ) {
      for ( long long int j = 0; j < 256; j++ ) {
	dp[i][j] = 0;
      }
    }
    dp[0][128] = 1;

    for ( long long int i = 1; i <= n; i++ ) {

      long long int in;
      cin >> in;
      for ( long long int j = 0; j < 256; j++ ) {

	if ( dp[i-1][j] > 0 ) {

	  for ( long long int k = 0; k < m; k++ ) {

	    long long int y = j + c[k];
	    if ( y < 0 ) y = 0;
	    if ( y > 255 ) y = 255;
	    long long int d = y - in;
	    d *= d;
	    d += dp[i-1][j];
	    if ( dp[i][y] == 0 || dp[i][y] > d ) dp[i][y] = d;

	  }

	}

      }

    }

    long long int ans = -1;

    for ( long long int i = 0; i < 256; i++ ) {

      if ( dp[n][i] > 0 ) {

	if ( ans == -1 || ans > dp[n][i] ) ans = dp[n][i];

      }

    }

    cout << ans-1 << endl;

  }

}

Measured memory_bytes: 41216
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}


int main(){
    long int n,min = pow107;
    cin >> n;
    for(int i = 1; i <= sqrt(n); ++i){
        if(n % i == 0){
            int count1 = 0,count2 = 0;
            long int x = i,y = n / i;
            while(x >= 1){
                count1++;
                x/=10;
            }
            while(y >= 1){
                count2++;
                y/=10;
            }
            int f = count1 > count2 ? count1 : count2;
            if(min > f){
                min = f;
            }
        }
    }
    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
const double eps=1e-10,Pi=acos(-1.0);
struct node{
	double x,y;
	node operator+(node b){return (node){x+b.x,y+b.y};}
	node operator-(node b){return (node){x-b.x,y-b.y};}
	node operator*(double b){return (node){x*b,y*b};}
	double len(){return sqrt(x*x+y*y);}
};
int fh(double a){return fabs(a)<eps?0:a>eps?1:-1;}
double cross(node a,node b){return a.x*b.y-a.y*b.x;}
double dot(node a,node b){return a.x*b.x+a.y*b.y;}
node projection(node p1,node p2,node p){node v=p2-p1;return p1+v*(dot(v,p-p1)/dot(v,v));}
node reflection(node p1,node p2,node p){node P=projection(p1,p2,p);P=P*2-p;return P;}
void Counter_Clockwise(node p1,node p2,node p){
	if(cross(p2-p1,p-p1)>eps){puts("COUNTER_CLOCKWISE");return;}
	if(cross(p2-p1,p-p1)<-eps){puts("CLOCKWISE");return;}
	if(dot(p2-p1,p-p1)<-eps){puts("ONLINE_BACK");return;}
	if(dot(p2-p1,p2-p1)>=dot(p-p1,p2-p1)){puts("ON_SEGMENT");return;}
	puts("ONLINE_FRONT");
}
bool insegment(node A,node B,node p){
	if(fh(cross(B-A,p-A)))return false;
	return ((fh(p.x-A.x)>=0 && fh(B.x-p.x)>=0) || (fh(p.x-A.x)<=0 && fh(B.x-p.x)<=0)) && ((fh(p.y-A.y)>=0 && fh(B.y-p.y)>=0) || (fh(p.y-A.y)<=0 && fh(B.y-p.y)<=0));
}
int parallel(node A1,node A2,node B1,node B2){
	if(!fh(cross(B2-B1,A2-A1)))return 2;
	if(!fh(dot(B2-B1,A2-A1)))return 1;
	return 0;
}
bool intersection(node A1,node A2,node B1,node B2){
	if(!fh(cross(B2-B1,A2-A1))){
		if(insegment(A1,A2,B1) || insegment(A1,A2,B2) || insegment(B1,B2,A1) || insegment(B1,B2,A2))return true;
		return false;
	}
	return fh(cross(A1-B1,B2-B1)*cross(A2-B1,B2-B1))<=0 && (fh(cross(B1-A1,A2-A1)*cross(B2-A1,A2-A1))<=0);
}
node getintersection(node A1,node A2,node B1,node B2){
	node v=A2-A1;
	return A1+v*(cross(B2-B1,B1-A1)/cross(B2-B1,A2-A1));
}
double distance(node A1,node A2,node B1,node B2){
	if(intersection(A1,A2,B1,B2))return 0.0;
	node p;double ans=1e18;
	ans=min(ans,(A1-B1).len());ans=min(ans,(A1-B2).len());ans=min(ans,(A2-B1).len());ans=min(ans,(A2-B2).len());
	p=projection(A1,A2,B1);
	if(insegment(A1,A2,p))ans=min(ans,(B1-p).len());
	p=projection(A1,A2,B2);
	if(insegment(A1,A2,p))ans=min(ans,(B2-p).len());
	p=projection(B1,B2,A1);
	if(insegment(B1,B2,p))ans=min(ans,(A1-p).len());
	p=projection(B1,B2,A2);
	if(insegment(B1,B2,p))ans=min(ans,(A2-p).len());
	return ans;
}
int main(){
	node p1,p2,p3,p4;
	int Q=gi();
	while(Q--){
		p1.x=gi();p1.y=gi();p2.x=gi();p2.y=gi();
		p3.x=gi();p3.y=gi();p4.x=gi();p4.y=gi();
		printf("%.8lf\n",distance(p1,p2,p3,p4));
	}
	return 0;
}



Measured memory_bytes: 3236
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> A, B, N;
  
  ll x = min((ll)B-1, (ll)N);


  return A * x / B;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3676
n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()

ans = sum(s)

if ans % 10 != 0:
    print(ans)
else:
    for x in s:
        if x % 10 != 0:
            ans -= x
            break
    if ans % 10 == 0:
        ans = 0
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli inf = 1e18;

int main(){
    lli n,p,q;
    cin >> n >> p >> q;
    vector<lli> c(n);
    for(int i=0; i<n; i++){
        cin >> c[i];
    }

    lli sum = 0;
    vector<lli> diff(n);
    for(int i=0; i<n; i++){
        sum += c[i];
        diff[i] = (q-i)*p -c[i];
    }
    sort(diff.begin(), diff.end(), greater<lli>());

    lli ans = sum;
    for(int i=0; i<n; i++){
        sum += diff[i] +i*2*p;
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
	ll s=0,N,K;
	cin >> N >> K;

	rep(i,N)
		s += max(0ll,i+1-K)*(N/(i+1))+max(0ll,N%(i+1)-K+1);

	cout << s-((K==0)*N) << endl;
}

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

using namespace std;
using ll = long long;

int n;
vector<vector<int>> hen;
vector<bool> seen;
vector<int> dist;

void bfs()
{
    queue<int> que;
    que.push(0);
    dist[0] = 0;
    seen[0] = true;
    while(que.size())
    {
        auto cur = que.front();
        que.pop();
        for(auto i : hen[cur]){
            if(seen[i])continue;
            seen[i] = true;
            dist[i] = dist[cur] + 1;
            que.push(i);
        }
    }
}




int main()
{
    cin >> n;
    hen.resize(n);
    dist.resize(n, -1);
    seen.resize(n);
    for(int i = 0; i < n; i++){
        int u, k; cin >> u >> k; u--;
        for(int j = 0; j < k; j++){
            int tmp; cin >> tmp; tmp--;
            hen[u].push_back(tmp);
        }
    }
    bfs();

    for(int i = 0; i < n; i++){
        cout << i + 1 << " " << dist[i] << endl;
    }


}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  vector<vector<ll>> dist(n, vector<ll>(n, INF));
  REP(i, n) dist[i][i] = 0;
  REP(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dist[a][b] = dist[b][a] = c;
  }
  REP(k, n)
  REP(i, n) REP(j, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  vector<vector<ll>> dist2(n, vector<ll>(n, INF));
  REP(i, n) REP(j, n) {
    if (dist[i][j] <= l) dist2[i][j] = 1;
  }
  REP(k, n)
  REP(i, n) REP(j, n) dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);

  ll q;
  cin >> q;
  REP(qi, q) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    ll ans = dist2[a][b] - 1;
    if (dist2[a][b] == INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace app02
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NX = Console.ReadLine().Split(' ');
            int N = int.Parse(NX[0]);
            int X = int.Parse(NX[1]);
            string[] L = Console.ReadLine().Split(' ');
            int[] intL = new int[N];
            int count = 1;
            int sum = 0;

            for (int i = 0; i < N; i++)
            {
                intL[i] = int.Parse(L[i]);
            }

            for (int i = 0; i < N; i++)
            {
                sum += intL[i];
                if (sum <= X)
                {
                    count++;
                }
            }
            Console.WriteLine($"{count}");

        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int main(void)
{
	int n, a[100], i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d", &a[i]);
	}
	for(i=n-1;i>0;i--){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[i]);
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V.at(i);

  vector<int> L(N);
  L.at(0) = V.at(0);
  for (int i = 1; i < N; i++) L.at(i) = __gcd(L.at(i - 1), V.at(i));

  vector<int> R(N);
  R.at(N - 1) = V.at(N - 1);
  for (int i = N - 2; i >= 0; i--) R.at(i) = __gcd(R.at(i + 1), V.at(i));

  int ans = R.at(1);
  for (int i = 1; i < N - 1; i++) ans = max(ans, __gcd(L.at(i - 1), R.at(i + 1)));

  cout << max(ans, L.at(N - 2)) << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>

using ll = long long;

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

    int left = 0;
    int right = 0;
    for (int i = 0; i < N; i++) {
        char c = S[i];
        if (c == '(') {
            left++;
        }
        else {
            if (left > 0)left--;
            else right++;
        }
    }

    std::string ans(right, '(');
    ans += S;
    ans += std::string(left, ')');
    std::cout << ans << std::endl;
}

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

using namespace std;

int main(void) {
    int n;
    long ans = 0;
    cin >> n;
    vector<int> a(n);
    cin >> a.at(0);
    for(int i = 1; i < n; i++){
        cin >> a.at(i);
        int tmp;
        if(a.at(i - 1) > a.at(i)){
            tmp = a.at(i - 1) - a.at(i);
            ans += tmp;
            a.at(i) += tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4020
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

//1. 自由に入れ替えられるグループを作る
//ex) (1, 2), (2, 5)→(1, 2, 5)
//2. 各グループについてindexと一致する値を数え上げる]
//ex) index(1, 2, 4) :value(2, 4, 7) → 2個

//UnionFindを使おう！

class UnionFind {
private:
	vector<int> par;

public:
	UnionFind(int N) {
		REP(i, N) par.push_back(i);
	}
	int getRoot(int x) {
		if (par[x] == x) return x;
		return par[x] = getRoot(par[x]);
	}
	void unite(int x, int y) {
		int rx = getRoot(x);
		int ry = getRoot(y);
		if (rx == ry) return;
		par[rx] = ry;
	}
	bool isSame(int x, int y) {
		return getRoot(x) == getRoot(y);
	}
};


signed main() {
	int N, M;
	cin >> N >> M;
	int p[100010];
	REP(i, N) cin >> p[i];

	UnionFind unionFind(N);
	REP(i, M) {
		int x, y;
		cin >> x >> y;
		unionFind.unite(x - 1, y - 1);
	}

	int ans = 0;
	REP(i, N) {
		// p[i]から1引くのを忘れない！(範囲が１～Nなので)
		if (unionFind.isSame(i, p[i] - 1)) ans++;
	}

	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 1392
import math
from sys import stdin


def get_result(data):
    A, B, C, D = data
    takahasi_q = math.ceil(float(A/D))
    aoiki_q = math.ceil(float(C/B))
    if takahasi_q == aoiki_q:
        return 'Yes'
    return 'Yes' if takahasi_q > aoiki_q else 'No'


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


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

int main()
{
    int r, c;
    cin >> r >> c;
    int ans[r + 1][c + 1];
    ans[r][c] = 0;

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

        for (int j = 0; j < c; j++)
        {
            cin >> ans[i][j];
            if (j == 0)
                ans[i][c] = 0;
            if (i == 0)
                ans[r][j] = 0;
            ans[i][c] += ans[i][j];
            ans[r][j] += ans[i][j];
        }
        ans[r][c] += ans[i][c];
    }
    for (int i = 0; i <= r; i++)
    {

        for (int j = 0; j <= c; j++)
        {
            cout << ans[i][j];
            if (j == c)
                continue;
            cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3108
#include<stdio.h>

int main(void){

  int N;
  scanf("%d", &N);

  int *a;
  a = (int *)malloc(N*sizeof(int));
  for(int i=0; i<N; i++){
    scanf("%d", &a[i]);
  }

  int ans=0;
  for(int i=0; i<N; i++){
    while(a[i]%2==0){
      a[i] = a[i]/2;
      ans++;
    }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;


int main(){

        int h,w;

        while(1){
                scanf("%d %d\n",&h,&w);
                if(h==0 && w==0)
                        return 0;
                for(int j=0;j<h;j++){
                        if(j==0 || j==h-1){
                                for(int i=0;i<w;i++) {
                                        putchar('#');

                                }
                        } else {
                                        putchar('#');
                                for(int i=1;i<w-1;i++) {
                                        putchar('.');

                                }
                                        putchar('#');
                        }
                        putchar('\n');
                }
                putchar('\n');
        }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	string s; cin >> s;
	string s_year = s.substr(0, 4);
	string s_month = s.substr(5, 2);
	string s_day = s.substr(8, 2);
	int a = stoi(s_year);
	int b = stoi(s_month);
	int c = stoi(s_day);
	if (a <= 2019 && b <= 4 && c <= 30) {
		cout << "Heisei" << endl;
		return;
	}
	cout << "TBD" << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
import math
# a=int(input())
#b=int(input())
# c=[]
# for i in b:
#     c.append(i)
e1,e2 = map(int,input().split())
f = list(map(int,input().split()))
#j = [input() for _ in range(3)]
cal=1
for i in range(e1-e2):
    if f[i]>=f[i+e2]:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 33072
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
#define all(x) x.begin(), x.end()
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define dbg(msg, var) cerr << msg << " " << var << endl;

using namespace std;

const int MAX = 200010;
const int MOD = 1000000007;
const int INF = 1e8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// End Template //

struct DSU {
    int n;
    vi parent, size;

    DSU(int n) {
        this->n = n;
        parent.assign(n+1, 0);
        size.assign(n+1, 1);

        for(int i=0;i<=n;i++)
            parent[i] = i;
    }

    int find(int v) {
        if(v==parent[v])
            return v;
        return parent[v]=find(parent[v]);
    }

    void join(int a, int b) {
        a = find(a);
        b = find(b);
        if(a!=b) {
            if(size[a]<size[b])
                swap(a, b);

            parent[b]=a;
            size[a]+=size[b];
        }
    }
};

int main()
{sws;

    int n, m, a, b;
    cin >> n >> m;
    DSU dsu(n+1);

    for(int i=0;i<m;i++){
        cin >> a >> b;
        dsu.join(a, b);
    }

    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(ans, dsu.size[dsu.find(i)]);
    }

    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 4716
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char ch;
queue<int> que;
signed main(){
    cin>>n>>m>>cnt;
    if(m*cnt>=n){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 10604
#include <stdio.h>
#include<string.h>
int a[3005];
int main(int argc, char *argv[])
{
	int n;
	 while(scanf("%d",&n)!=EOF){
 		for(int i=0;i<n;i++)
 		  scanf("%d",&a[i]);
 		  int sum=0;
 		for(int i=0;i<n;i++)
		    sum+=a[i]-1;
		printf("%d\n",sum);    
 	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}


int main() {
    int n,m; cin >> n >> m;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    Graph G(n);
    rep(i, m) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    rep(i, n) {
        bool flag = true;
        rep(j, G[i].size()) {
            if(h[i] <= h[G[i][j]]) {
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9068
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K;
    cin >> N >> K;

    int k = (N - 2) * (N - 1) / 2;

    if (K > k) {
        print(-1);
        return 0;
    }

    vector<pair<int, int>> ans;
    REP(i, N - 1) {
        ans.eb(1, i + 2);
    }

    int i = 2, j = 3;
    while(k > K && i < N + 1 && j < N + 1) {
        if (i == j) {
            if (j == N) {
                i++; j = i + 1;
            } else {
                j++;
            }
        }

        ans.eb(i, j);
        k--;

        if (j == N) {
            i++; j = i + 1;
        } else {
            j++;
        }
    }

    if (k != K) {
        print(-1);
        return 0;
    }

    print(ans.size());
    for(auto &e: ans) {
        cout << e.fi << " " << e.se << endl;
    }

}


Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int a = 0, b = 0, c = 0,k = 0;
int canuse[10] = {};
vector<int> v;
string n;

int main() {
		
	cin >> n >> k;
	for(int i = 0; i < k; i++) {
		int umaru = 0;
		cin >> umaru;
		canuse[umaru] = 1;
	
	}



	for (int i = stoi(n); i < 1e6; i++) {

		bool out = false;

		n = to_string(i);


		for (int j = 0; j < n.length(); j++) {

			string temp;
			temp = n[j];

			if (canuse[stoi(temp)] == 1) {
			
				out = true;
			}

		}

		if (!out) {
			cout << n << endl;
			return 0;
		}

	}


}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

ll func(ll n){
    ll res = n%10;
    while(n/10 != 0){
        n /= 10;
        res += n%10;
    }
    return res;
}
int main(){

    ll n;
    cin >> n;
    if(n % func(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647
/*
 add(a,b,x): [a,b) にxを加算する。
 getSum(a,b):[a,b)の区間の合計を取得する。log オーダー 
 
*/

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> A(n);
    rep(i, n)
    {
        cin >> A[i];
    }
    //imos法を実装する。
    vector<ll> imos(n + 5); //スタートに1、終わった次のところに-1
    vector<ll> imos2(n + 5);
    rep(j, k)
    {
        rep(i, n)
        {
            imos[max((ll)0, i - A[i])] += 1;
            imos[min((ll)n, i + A[i] + 1)] += -1;
        }
        A[0] = imos[0];
        for (int i = 1; i < n; i++)
        {
            imos[i] += imos[i - 1];
            A[i] = imos[i];
        }
        int flag = 0;
        rep(i, n)
        {
            if (A[i] != n)
            {
                flag = 1;
                break;
            }
        }
        if (flag == 0)
        {
            break;
        }
        imos = imos2;
    }
    rep(i, n)
    {
        cout << A[i] << " ";
    }
}


Measured memory_bytes: 7912
def score(n)
  Rational(n, s(n))
end
def s(n)
  n.to_s.chars.map(&:to_i).inject(:+)
end
def f(n)
  r = n+1
  s = score(r)
  15.times.map{|i|10**i}.each do |i|
    m = n+i
    next if s <= score(m)
    s = score(m)
    r = m
  end
  r
end
n=1
gets.to_i.times do
  p n
  n = f(n)
end


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
    int N , A , B;
    cin >> N >> A >> B;
    int T = B - A - 1;
    if(T % 2 == 0){
        cout << "Borys" << endl;
    }
    else{
        cout << "Alice" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

int main()
{
    int N, K;
    if (scanf("%d%d", &N, &K) < 2) return 0;

    vector<int> l(N);
    for (int i = 0; i < N; i++) if (scanf("%d", &l[i]) < 1) return 0;

    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    for (int j = 0; j < K; j++) ans += l[j];

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int x,y,d,a;
  scanf("%d%d",&x,&y);
  //x>yであるために
  if(x<y){
    a = x;
    x = y;
    y = a;
  }
  //互除法
  d = x % y;
  while(d!=0){
    x = y;
    y = d;
    d = x % y;
  }
  printf("%d\n",y);
return 0;
}


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

using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) cout << "GREATER" << endl;
	else if (a.size() < b.size()) cout << "LESS" << endl;
	else if (a == b) cout << "EQUAL" << endl;
	else if (a > b) cout << "GREATER" << endl;
	else cout << "LESS" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int N, A[22], B[22], C[22];

int main()
{
	scanf ("%d", &N);
	for (int i = 1; i <= N; i++) scanf ("%d", &A[i]);
	for (int i = 1; i <= N; i++) scanf ("%d", &B[i]);
	for (int i = 1; i < N; i++) scanf ("%d", &C[i]);

	int a = 0;
	for (int i = 1, L = N + 2; i <= N; i++){
		a += B[A[i]];
		if (L + 1 == A[i]) a += C[L];
		L = A[i];
	}
	printf ("%d\n", a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>

#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
using namespace std;

int main(){
  ll N;
  cin >> N;
  ll a[200010];
  //int a[]={1,4,6,3,5};
  FOR(i, 0, N) cin >> a[i];
  FOR(i, 0, N) a[i] -= i+1;
  
  sort(a, a+N);
  
  ll m;
  if(N%2==0) m = (a[N/2] + a[N/2-1])/2;
  else m = a[N/2];
  
  ll ans1 = 0;
  ll ans2 = 0;
  ll ans3 = 0;
  
  FOR(i, 0, N) ans1+=abs(a[i]-m);
  FOR(i, 0, N) ans2+=abs(a[i]-m-1);
  FOR(i, 0, N) ans3+=abs(a[i]-m+1);
  
  cout << min({ans1, ans2, ans3}) << endl;
  
  //ll sum = 0;
  //FOR(i, 0, N) sum += a[i];
  //sum /= N;
    
  //int ans1 = 0;
  //int ans2 = 0;
  //int ans3 = 0;
  
  //FOR(i, 0, N) ans1+=abs(a[i]-sum);
  //FOR(i, 0, N) ans2+=abs(a[i]-sum-1);
  //FOR(i, 0, N) ans3+=abs(a[i]-sum+1);
  
  //cout << min({ans1, ans2, ans3}) << endl;

}

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

class hapiness{
    public:
        int a,b, c;
};

int vacation(vector<hapiness> v, int n){
    hapiness *dp = new hapiness[n];
    dp[0].a = v[0].a;
    dp[0].b = v[0].b;
    dp[0].c = v[0].c; 

    for(int i=1;i<n;i++){
        dp[i].a = v[i].a + max(dp[i-1].b, dp[i-1].c);
        dp[i].b = v[i].b + max(dp[i-1].a, dp[i-1].c);
        dp[i].c = v[i].c + max(dp[i-1].a, dp[i-1].b);
    }

    return max(dp[n-1].a, max(dp[n-1].b, dp[n-1].c));
}

int main() {
    int n;
    cin >> n;
    vector<hapiness> v;

    for(int i=0;i<n;i++){
        int a,b,c;
        cin >> a >> b >> c;
        hapiness t;
        t.a = a;
        t.b = b;
        t.c = c;
        v.push_back(t);
    }

    cout << vacation(v, n) <<endl;
}


Measured memory_bytes: 6832
#include <iostream>
using namespace std;
long long k,a,b,i;
int main()
{
    cin>>k>>a>>b;
    for (i=a;i<=b;++i)
    {
        if (i%k==0)
        {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  ll ans=0;
  rep(i,1<<s.size()-1){
    ll a=0;
    rep(j,s.size()){
      a+=s[j]-'0';
      if((i>>j)&1==1) a*=10;
      else {ans+=a; a=0;}
    }
    ans+=a;
  }
  cout << ans << endl;
  return 0;
}

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

ll gcd(ll a , ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
  int n;
  cin >> n;
  ll t[n];
  rep(i, n) cin >> t[i];
  ll ans = t[0];
  rep(i, n) ans *= (t[i]/gcd(t[i],ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//9-A
 
import java.util.Scanner;
 
class Main {
    public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
         
        while(true){
        	
            String s = sc.next();//??¢??????????????????
            
            if(s.equals("-")){
                break;
            }
            
            int n = sc.nextInt();//?????£??????????????°
            
            for(int i = 0; i < n; ++i){
                int h = sc.nextInt();//???????????????????????????????????????
                String up = s.substring(0, h);//substring??§0-h???????????¨?????????
                String down = s.substring(h);//substring??§h??????????????¨?????????
                
                s = down + up;//??????????????????????????¢??????????????£?????????
            }
            
            System.out.println(s);
        }
    }
}

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

string s, a[9] = {"", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
int main() {
	int i;
	cin >> s;
	for(i=1; i<=7; i++) if(a[i]==s) break;
	cout << i;
	return 0;
}


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

class dice {
public:
	int getRightFace(int top, int front);
	void setFaceNumber(int *number);
private:
	int face[6];
};

void dice::setFaceNumber(int *number) {
	for(int i=0; i<6; ++i) {
		face[i]=number[i];
	}
}

int dice::getRightFace(int top, int front) {
	int pos_top, pos_front;
	string str;
	string target_str;
	for(int i=0; i<6; ++i) {
		if(face[i]==top) pos_top=i;
		if(face[i]==front) pos_front=i;
	}
	str = to_string(pos_top)+to_string(pos_front);
	target_str="01540";
	if((int)target_str.find(str)!=-1) {
		return face[2];
	}
	target_str="04510";
	if((int)target_str.find(str)!=-1) {
		return face[3];
	}
	target_str="02530";
	if((int)target_str.find(str)!=-1) {
		return face[4];
	}
	target_str="03520";
	if((int)target_str.find(str)!=-1) {
		return face[1];
	}
	target_str="12431";
	if((int)target_str.find(str)!=-1) {
		return face[0];
	}
	target_str="13421";
	if((int)target_str.find(str)!=-1) {
		return face[5];
	}
	return 0;
}

int main() {
	int num[6];
	int n,top,front;
	dice d;
	cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4] >> num[5];
	d.setFaceNumber(num);
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> top >> front;
		cout << d.getRightFace(top,front) << endl;
	}
	return 0;
}

Measured memory_bytes: 3240
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;

	}
	else if(a>b){
	cout<<"a > b"<<endl;
	}

	else if(a==b){
	cout<<"a == b"<<endl;
	}
return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	int n = s.size();
	vector<int> a(n + 1, 0);
	for (int i = 0; i < n; ++i) {
		if (s[i] == '<') {
			a[i + 1] = max(a[i + 1], a[i] + 1);
		}
	}
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == '>') {
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}

	Int ans = 0;
	for (int i = 0; i < a.size(); ++i) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2820