akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
const int MAXN = 200005;
int cnt[MAXN];
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i],cnt[a[i]]++;
	int currSum = 0;
	for(int i=1;i<=MAXN;i++)if(cnt[i]>0)currSum++;
	int res = 0;
	if(currSum>k)
	{
		sort(cnt,cnt+MAXN);
		for(int i=1;i<=MAXN&&currSum!=k;i++)
		{
			if(cnt[i]>0)
				currSum-=1,res+=cnt[i];
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>

using namespace std;

#define ll long long 

int main() {
    string in;
    cin>>in;
    int i=0;
    while(i<4) {
        if(in[i] == in[i+1]) {
            cout<<"Bad"<<endl;
            return 0;
        } else {
            i += 1;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.reflect.Array;
import java.math.*;
import java.text.DecimalFormat;
import java.util.*;




public class Main {


    public static void main(String[] args) throws Exception{
        IO io = new IO(null,null);
        int n = io.getNextInt();
        long x = io.getNextInt();
        int [] A = new int[n];
        int [] B = new int[n];
        for (int i = 0;i < n;i++)
            A[i] = io.getNextInt();

        for (int i = 0;i < n;i++) B[i] = A[i];
        long ans = Long.MAX_VALUE;
        for (int k = 0;k <= n;k++) {
            long sum = k*x;
            for (int i = 0;i < n;i++) sum += B[i];
            ans = Math.min(ans,sum);

            for (int i = 0;i < n;i++){
                int j = (i + k + 1)%n;
                B[j] = Math.min(B[j],A[i]);
            }
        }
        io.println(ans);

        io.close();
    }
}



class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public boolean hasMore() throws IOException{
        if(st != null && st.hasMoreTokens()) return true;
        if(br != null && br.ready()) return true;
        return false;
    }
    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine().trim();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
    public void outputArr(Object [] A) throws IOException{
        int L = A.length;
        for (int i = 0;i < L;i++) {
            if(i > 0) writer.print(" ");
            writer.print(A[i]);
        }
        writer.print("\n");
    }
}


Measured memory_bytes: 23964
def main():
    N = int(input())
    S = input()
    dsw = tuple([("S", "S"), ("S", "W"), ("W", "S"), ("W", "W")])
    for d1, d2 in dsw:
        cur = d1+d2
        for s in S[1:N-1]:
            if cur[-1] == "S":
                if s == "o":
                    cur += cur[-2]
                else:
                    cur += ("W" if cur[-2] == "S" else "S")
            else:
                if s == "o":
                    cur += ("W" if cur[-2] == "S" else "S")
                else:
                    cur += cur[-2]
        flag = False
        if cur[-1] == "S":
            if S[-1] == "o":
                flag = (cur[-2] == cur[0])
            else:
                flag = (cur[-2] != cur[0])
        else:
            if S[-1] == "o":
                flag = (cur[-2] != cur[0])
            else:
                flag = (cur[-2] == cur[0])
        if flag:
            if cur[0] == "S":
                if S[0] == "o":
                    flag = (cur[-1] == cur[1])
                else:
                    flag = (cur[-1] != cur[1])
            else:
                if S[0] == "o":
                    flag = (cur[-1] != cur[1])
                else:
                    flag = (cur[-1] == cur[1])
        if flag:
            return print(cur)

    print(-1)


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  int v[n],c[n],a[n],h=0;
  for(int i=0;i<n;i++){
	cin >> v[i];
  }
  for(int i=0;i<n;i++){
	cin >> c[i];
    a[i] = v[i]-c[i];
    if(a[i]>0) h += a[i];
  }
    
  cout << h << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(abs(b-a) <= d && abs(c-b) <= d) Yes;
    else if(abs(c-a) <= d) Yes;
    else No;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//#define int long long
#define F first
#define S second

int main() {
	ios::sync_with_stdio(false);
	long long n, a, b;
	cin >> n >> a >> b;
	if (a > b)
		swap(a, b);
	if ((a - b) % 2 == 0)
		cout << (b - a) / 2;
	else
		cout << min(a + (b - a) / 2, n - b + 1 + (b - a) / 2);
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <cmath>

#pragma GCC optimize("O3")

using namespace std;
typedef long long ll;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    bool ok = false;
    if ((a+b-c)*(a+b-c) > 4*a*b) ok = true;
    if (a+b >= c) ok = false;

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main()
{
	int N,W;
	cin >> N >> W;
	vector<long> weight(N), value(N);
	for(int i=0 ; i<N ; i++)
		cin >> weight[i] >> value[i];
	vector<vector<long> > dp(N+1,vector<long>(W+1,0));
	for(int i=1 ; i<=N ; i++)
		for(int j=1 ; j<=W ; j++)
		{
			if(weight[i-1] > j)
				dp[i][j] = dp[i-1][j];
			else
				dp[i][j] = max(dp[i-1][j],value[i-1]+dp[i-1][j-weight[i-1]]);
		}
	cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
using System;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var t = ReadIntArray();
	int ab = t[0], bc = t[1]; // ca = t[2];
	WriteLine(ab*bc/2);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,l;
	cin >> n;
	vector<int> v(n);
	vector<int> x(n,0);
	for (int i = 0; i < n; i++){
		cin >> l;
		v[i] = l;
	}
	x[0] = 1;
	int next =v[0];
	int counter = 1;
	int flag = 0;
	while(next != 2){
		x[next - 1] ++;
		if (x[next - 1] <2){
			next = v[next - 1];
			counter++;
		}
		else{
			flag = 1;
			break;
		}
	}
	if (flag == 0){
		cout << counter << endl;
	}
	else{
		cout << -1 << endl;
	}

	return 0;
}

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

int main() {
	int r, g, b;
	int num = 0;

	cin >> r >> g >> b;

	num = g * 10 + b;

	if((num % 4) == 0){
		cout << "YES";
	}
	else{
		cout << "NO";
	}

}


Measured memory_bytes: 768
n = gets.to_i
ac = "AC"
wa = "WA"
tle = "TLE"
re = "RE"
c = [0, 0, 0, 0]
n.times do |i|
  case gets.chomp
  when ac
    c[0] += 1
  when wa
    c[1] += 1
  when tle
    c[2] += 1
  when re
    c[3] += 1
  end
end
puts ac + " x " + c[0].to_s
puts wa + " x " + c[1].to_s
puts tle + " x " + c[2].to_s
puts re + " x " + c[3].to_s

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

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

  long int sum = 0;
  unordered_map<string, int> num(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (num.count(s)) {
      sum += num[s];
      num[s]++;
    } else
      num[s]++;
  }

  cout << sum << endl;
}

Measured memory_bytes: 10496
N =int(input())
p = [list(map(int,input().split())) for _ in range(N)]

import itertools,math

ptr = list(itertools.permutations(range(N),N))

def dist(p1,p2):
  return math.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)

total = 0

for pt in ptr:
  for i in range(len(p)-1):
    total += dist(p[pt[i]] ,p[pt[i+1]])  
print(total/len(ptr))



Measured memory_bytes: 7972
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
    int num;
    cin >> num;
    string a,b;
    cin >> a >> b;
    for(int i=0; i<num; i++){
        cout << a[i] << b[i];
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,m,n) for (int i = m; i < (n); ++i)
#define REPR(i,n) for (int i = n; i >= 0; --i)
#define P pair<int, int>
const int INF = 1e9;
using namespace std;

int contest,goal;

int main() {
    //ボーナスとるかとらないかをbit全探索で表現
    //ボーナス
    cin >> contest >> goal;
    goal /= 100; // 100かける処理を省くため
    int theNumberOfProblems[contest];
    int bonus[contest];
        int ans = 100000000;//これを更新して最小値を出力
    REP(i,contest) {
        cin >> theNumberOfProblems[i] >> bonus[i];
        bonus[i] /= 100;
    }
    REP(x,1<<contest) {
        int score=0;
        int cnt=0;
        //ボーナスを加算していって、ボーナスだけでゴールを超えないぎりぎりの回でポイントを加算していく
        //ギリギリの回は、theNumberOfProblemsのインデックスが大きい順で見ていく
        REP(i,contest) /*各ビットの検査*/{
            if(x&(1<<i)) {
                //ある回の問題数すべてとボーナスをスコアに加算
                cnt+=theNumberOfProblems[i];
                score+=bonus[i]+theNumberOfProblems[i]*(i+1);
            }
        }
        //scoreがgoal以上なら、最小値を更新し、次のパターンへ
        if(score >= goal) {
                ans=min(ans,cnt);
                continue;
            }
        //もし、不足していれば得点が大きい回から順にループ
        REPR(i,contest-1) {
            //ボーナスが出ていなければ、その回の一問分の得点をループで足していく
            if(!(x&(1<<i))) {
                //score>=goalとなるまで、また、その回の問題数が
                int tmp=theNumberOfProblems[i];//ボーナスで不十分の場合使いまわす可能性があるのでtmpを使う
                while(tmp) {
                    //
                    score += i+1;
                    tmp--;
                    cnt++;
                    if(score >= goal) {
                        ans=min(ans,cnt);
                        break;
                    }
                }
                break;
            }
        }
    }
        cout << ans << endl;
    //score = ボーナス + ボーナス取得回の得点 + ボーナス非取得回の得点
}

Measured memory_bytes: 3604
n, m = map(int, input().split())
l = []
edges = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    l.append([a - 1, b - 1])
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
def dfs(cur, a, b):
    if visited[cur] == 1:
        return None
    visited[cur] = 1
    for v in edges[cur]:
        if v != b or cur != a:
            dfs(v, a, b)
ans = 0
for i in l:
    i, j = i[0], i[1]
    visited = [0 for i in range(n)]
    dfs(i, i, j)
    if visited[j] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9244
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<string> s(n);
    REP(i, n){
        string temp; cin >> temp;
        whole(sort, temp);
        s[i] = temp;
    }
    whole(sort, s);
    ll ans = 0, cnt = 0;
    REP(i, n){
        cnt++;
        if((i < n - 1 and s[i] != s[i + 1]) or i == n - 1){
            ans += (cnt * (cnt - 1)) / 2;
            cnt = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int s, t, d;
    cin >> s >> t >> d;
    vector<ll> v(d);
    for(int i = 0; i < d; i++)  cin >> v[i], v[i] *= -1;
    ll target = s-t;
    ll sum = 0, ma = 0;
    for(int i = 0; i < d; i++){
        sum += v[i];
        if(sum >= target){
            cout << i+1 << endl;
            return 0;
        }
        ma = max(ma, sum);
    }
    if(sum <= 0){
        cout << -1 << endl;
        return 0;
    }
    ll ans = (target-ma+sum-1)/sum*d;
    target -= (target-ma+sum-1)/sum*sum;
    for(int i = 0; i <= d; i++){
        if(target <= 0){
            cout << ans+i << endl;
            return 0;
        }
        if(i < d)   target -= v[i];
    }
}



Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
    long A,B,C,X,Y;
    std::cin >> A >> B >> C >> X >> Y;
    if(A+B<=C*2){
        std::cout << A*X+B*Y << std::endl;
    }else{
        if(X<Y){
            long temp;
            temp=X;
            X=Y;
            Y=temp;
            temp=A;
            A=B;
            B=temp;
        }
        long value=2*Y*C;
        X=X-Y;
        if(A>=2*C){
            value+=2*X*C;
        }else{
            value+=A*X;
        }
        std::cout << value << std::endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

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

    int N;
    cin >> N;

    map<string, int> hs;

    ll ans = 0;

    while (N--)
    {
        string s;
        cin >> s;

        sort(s.begin(), s.end());

        auto it = hs.find(s);

        if (it != hs.end())
            ans += it->second;

        ++hs[s];
    }        

    cout << ans << '\n';

    return 0;
}


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

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    string s; cin >> s;

    int cnt = 1;
    for(int i = 1; i < n; ++i){
        if(s[i-1] != s[i]) ++cnt;
    }

    cout << cnt << endl;

return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n;
	string u[n];
	for(int i=0;i<n;i++){
		cin >> u[i];
	}
	cin >> m;
	string t[m];
	int l=0;
	for(int i=0;i<m;i++){
		cin >> t[i];
		for(int j=0;j<n;j++){
			if((t[i]==u[j]) && (l%2==0)){
				cout << "Opened by " << t[i];
				l++;
				break;
			}else if((t[i]==u[j]) && (l%2==1)){
				cout << "Closed by " << t[i];
				l++;
				break;
			}
			if(j==n-1){
				cout << "Unknown " << t[i];
				break;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3216
def myAnswer(N:int,dic:dict) -> int:
   ans = 0
   for a in dic.values():
      if(a % 2 == 1):
         ans += 1
   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   dic = {}
   for _ in range(N):
      a = int(input())
      if(a in dic.keys()):
         dic[a]+=1
      else:
         dic[a]=1
   print(myAnswer(N,dic))
if __name__ == '__main__':
   main()

Measured memory_bytes: 15076
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#include <fstream>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int main() {
	int i, j, k;
	int N, M, K;

	int D, T, S;
	cin >> D >> T >> S;
	if (D > T * S) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

}


Measured memory_bytes: 3624
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define ld long double
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int s,w;
    void solve()
    {
        cin>>s>>w;
        if(w>=s)
        {
            cout<<"unsafe"<<endl;
        }
        else
            cout<<"safe"<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3620
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main()
{	
	int n,m,i;
	int t[110],p[110],x[110];
	int sum=0;
	scanf("%d",&n);
	for( i=1;i<=n;i++)
	{
		scanf("%d",&t[i]);
		sum+=t[i];
	}
	scanf("%d",&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&p[i],&x[i]);
	}
	for(i=1;i<=m;i++)
	{
		int j=p[i];
		int ans=sum-t[j]+x[i];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
a, b, c = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
num = 0
for i in range(a):
    A = list(map(int, input().split()))
    for i in range(b):
        num += A[i] * X[i]
    if(num + c > 0):
        ans += 1
    num = 0
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const pair<int, int> MaxCount(const map<int, int> &countMap)
{
    int maxValue = 0;
    int maxCount = 0;
    for (const auto &kvp : countMap)
    {
        if (kvp.second > maxCount)
        {
            maxValue = kvp.first;
            maxCount = kvp.second;
        }
    }
    return{ maxValue, maxCount };
}

const int SecondMaxCount(const map<int, int> &countMap, const int NG)
{
    int secondMaxCount = 0;
    for (const auto &kvp : countMap)
    {
        if (kvp.first != NG && kvp.second > secondMaxCount)
        {
            secondMaxCount = kvp.second;
        }
    }
    return secondMaxCount;
}

int main()
{
    int n;
    cin >> n;
    vector<map<int, int>> countMaps(2);
    for (int i = 0; i < n; ++i)
    {
        int vi;
        cin >> vi;
        countMaps[i % 2][vi] += 1;
    }
    const auto maxPair0 = MaxCount(countMaps[0]);
    const auto maxPair1 = MaxCount(countMaps[1]);
    if (maxPair0.first != maxPair1.first)
    {
        cout << n - maxPair0.second - maxPair1.second << endl;
    }
    else
    {
        const int secondMaxCount0 = SecondMaxCount(countMaps[0], maxPair0.first);
        const int secondMaxCount1 = SecondMaxCount(countMaps[1], maxPair0.first);
        secondMaxCount0 > secondMaxCount1 ?
            cout << n - secondMaxCount0 - maxPair1.second << endl :
            cout << n - maxPair0.second - secondMaxCount1 << endl;
    }
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
// "bits/stdc++.h"  " " cause i am using the precompiled header file
// i have already created the precompilede file in the directory
using namespace std;

#define GodSpeed ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()
{
	GodSpeed;
	long long a, b, x;
	cin >> a >> b >> x;
	// long long count = 0;
	if (a % x == 0)
		cout << (b / x) - (a / x) + 1;
	else
		cout << (b / x) - (a / x);

	return 0;
}

Measured memory_bytes: 3616
//18B
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    string s;
    while(true){
        cin >> s;
        if(s=="0"){
            break;
        }
        int sum=0;
        for(int i=0;i<s.size();i++){
            
            int n=s[i]-48;
            //cout <<"'"<< s[i] << "'"<<n<<endl;
            sum += n;
        }
        cout << sum <<endl;
    }
}



Measured memory_bytes: 3164
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<functional>
#include<cmath>

using namespace std;

typedef long long ll;

int student[32];

int main()
{
	int a;
	for (int i = 0; i < 28; i++) {
		cin >> a;
		student[a] = 1;
	}
	for (int i = 1; i <= 30; i++) {
		if (student[i] == 0)cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 3052
n=int(input())
a=list(map(int, input().split()))
ans=[]
x=max(a)
ans.append(x)
a.remove(max(a))
y=x/2
b=10**10
d=10**10

for i in range(n-1):
    c=abs(a[i]-y)
    if b>c:
        d=a[i]
    b=min(b,c)
ans.append(d)
print(*ans)





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

using namespace std;

#define ll long long

const int N=1e6+5;

int n,t[N],ans,x,cnt[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    
    int a,b;
    scanf("%d %d",&a,&b);
    if ((b-a)%2==0){
        printf("%d\n",(a+b)/2);
    }
    else
        printf("IMPOSSIBLE\n");
}



Measured memory_bytes: 256
#include<cstdio> 
#include<cmath>
#include<iostream>
using namespace std;
long long n,ans; 
int s;
int main()
{
    cin>>n;
    for(int i=sqrt(n);i>0;--i) 
    if(n%i==0)
	{
        ans=n/i;
        break;
    }
    while(ans>0)
	{
        ++s;
        ans/=10;
    }
    cout<<s<<endl;
    return 0;
}

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

#define fio() ios_base::sync_with_stdio(false);\
cin.tie(NULL);

#define md 1000000007
#define mem(arr,x) memset(arr,x,sizeof(arr))
#define pb push_back
#define vi vector<lli>
#define vvi vi<vi>
typedef long long int lli;
typedef float fl;

bool sortinrev(const pair<lli, lli > &a,     const pair<lli , lli > &b)
{
	return (a.first > b.first);
}
int main()
{
	fio();
	lli t = 1 ;
	//cin >> t;
	while(t--)
	{
		lli a, b, c, d;
		cin >> a >> b >> c >> d;
		lli ans = max ( {a * c , a * d , b * c , b * d} );
		cout << ans ;
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  int l, r;
  vector<int> order(n);
  iota(order.begin(),order.end(),1);
  int cnt = 0;
  do{
    if(p == order) l = cnt;
    if(q == order) r = cnt;
    cnt++;
  }while(next_permutation(order.begin(),order.end()));
  cout << abs(l - r) << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
c = []
s = []
f = []

for i in range(n-1):
	x,y,z = map(int,input().split())
	c.append(x)
	s.append(y)
	f.append(z)
time = 0

#それぞれの駅から出発する
for i in range(n-1):
	for j in range(i,n-1):
		if time <= s[j]:
			time = s[j] + c[j]
		elif time%f[j] == 0:
			time += c[j]
		else:
			time += f[j]-(time%f[j]) + c[j]
	print(time)
	time = 0
print(0)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)



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

    int i_range;
    i_range = min(k,n-k+1);
    //cout << i_range << endl;
    int num;
    num = max(k-1,n-k+1);

    ll** comb;
    comb = new ll*[num+1];
    for (int i = 0; i < num+1; i++)
    {
        comb[i] = new ll[num+1];
        for (int j = 0; j < num+1; j++)
        {
            comb[i][j] = 0;
        }
        
    }
    comb[0][0] = 1;

    
    for (int i = 1; i < num+1; i++)
    {
        for (int j = 0; j < i+1; j++)
        {
            if (j==0||j==i)
            {
                comb[i][j] = 1;
            }else
            {
                comb[i][j] = comb[i-1][j-1]+comb[i-1][j];
            }
            
            comb[i][j]%=MOD;
            
        }
        
    }

    //cout << "check" << comb[10][3]<< endl;

    ll* ans;
    ans = new ll[i_range];
    for (int i = 1; i < i_range+1; i++)
    {
        ans[i] = (comb[k-1][i-1]*comb[n-k+1][i])%MOD;
    }
    for (int i = i_range+1; i < k+1; i++)
    {
        ans[i] = 0;
    }
    

    for (int i = 1; i < k+1; i++)
    {
        cout << ans[i] << endl;
    }
    
}

Measured memory_bytes: 31616
import math


def is_prime(num):
    if num == 2:
        return True
    elif not num & 1:
        return False

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


N = int(input())
nums = [int(input()) for _ in range(N)]
ans = len([num for num in nums if is_prime(num)])
print(ans)

Measured memory_bytes: 8036
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] d = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scanner.nextInt();
			sum = sum + d[i];
		}
		int diff = sum;
		int s1 = 0;
		for (int i = 0; i < n; i++) {
			s1 = s1 + d[i];
			int sabun = Math.abs((sum - s1) - s1);
			if (diff < sabun) {
				break;
			} else {
				diff = sabun;
			}
		}
		System.out.println(diff);
	}
}


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

long long  N, K;
vector<long long> A(200001);
vector<long long> Past(200001, -1);
long long l_start;
long long l_loop;


void searchRoot(long long i, long long now)
{
	if (Past[now] == -1)
	{
		Past[now] = i;
		searchRoot(i + 1, A[now]);
	}
	else
	{
		l_start = Past[now]; //何回目からループ？
		l_loop = i - Past[now]; // ループの長さ
	}
}

int main(void)
{
	cin >> N >> K;
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}
	searchRoot(0, 1);

	long long target;
	if (K > l_start)
	{
		target = l_start + ((K - l_start) % l_loop);
	}
	else
	{
		target = K;
	}

	for (int n = 1; n <= N; n++)
	{
		if (Past[n] == target)
		{
			cout << n;
			break;
		}
	}
}

Measured memory_bytes: 6280
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

vector<pll> v[100005];
ll d[100005];

void dfs(int at,int p,ll c=0)
{
	d[at]=c;
	tr(v[at],it)
	{
		int to=it->ff;
		ll cc=it->ss;
		if(to!=p)
		{
			dfs(to,at,c+cc);
		}
	}
}

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
rep(i,1,n-1)
{
	ll a,b,c;
	cin>>a>>b>>c;
	v[a].pb(mp(b,c));
	v[b].pb(mp(a,c));
}
ll q,k;
cin>>q>>k;
dfs(k,0);

while(q--)
{
	int x,y;
	cin>>x>>y;
	ol(d[x]+d[y]);on;
}
return 0;
}



Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define inf (long long)1e17
using namespace std;

long long n;
string s;
vector<vector<long long>> dpmax, dpmin;

long long solve(int l, int r);

int main() {
  cin >> s;
  n = s.size();
  dpmax.assign(n + 1, vector<long long>(n + 1, inf));
  dpmin.assign(n + 1, vector<long long>(n + 1, inf));
  cout << solve(0, n) << endl;
  return 0;
}

long long solve(int l, int r) {
  if(dpmax[l][r] != inf) return dpmax[l][r];
  bool ch = 1;
  // x))))))
  for(int i = l + 1; i < r; ++i)
    if(s[i] != ')') ch = 0;
  if(ch) return dpmax[l][r] = dpmin[l][r] = s[l] - '0';
  ch = 1;
  // ((((((x
  for(int i = l; i < r - 1; ++i)
    if(s[i] != '(') ch = 0;
  if(ch) return dpmax[l][r] = dpmin[l][r] = s[r - 1] - '0';
  // x)+y...
  if(r - l > 2 && s[l + 1] == ')')
    return dpmax[l][r] = -inf;
  // ...+y(x
  if(r - l > 2 && s[r - 2] == '(')
    return dpmax[l][r] = -inf;
  long long resmax = -inf, resmin = inf;
  for(int i = l; i < r; ++i)
    if(s[i] == '+') {
      resmax = max(resmax, solve(l, i) + solve(i + 1, r));
      resmin = min(resmin, dpmin[l][i] + dpmin[i + 1][r]);
    }
    else if(s[i] == '-') {
      solve(i + 1, r);
      resmax = max(resmax, solve(l, i) - dpmin[i + 1][r]);
      resmin = min(resmin, dpmin[l][i] - dpmax[i + 1][r]);
    }
  dpmin[l][r] = resmin;
  return dpmax[l][r] = resmax;
}


Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

// a^n mod を計算する
ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % 2019;
		a = a * a % 2019;
		n >>= 1;
	}
	return res;
}

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

	ll N, T;
	cin >> N >> T;

	vector<ll> t(N);
	cin >> t[0];
	repk(i,1, N) {
		cin >> t[i];
		if (t[i] - t[i - 1] <= T) {
			ans += t[i] - t[i - 1];
		}
		else {
			ans += T;
		}
	}


	cout << ans + T << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

bool isPrime(ll n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    double sqrtNum = sqrt(n);
    for (int i=3; i<=sqrtNum; i+=2){
        if (n%i == 0){
            return false;
        }
    }
    return true;
}

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

    // input
    int N;
    cin >> N;

    vector<int> primes;
    FOR(i, 0, 1000){
        ll a = 6 + 5 * i;
        if(isPrime(a)){
            primes.push_back(a);

            if(primes.size() == N){
                break;
            }
        }
    }

    FOR(i, 0, N){
        cout << primes[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a < b && b < c)
    {
        printf("Yes\n");     
    }
    else
    {
         printf("No\n");
    }
    return 0;    
} 


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


int main() {
    string a;
    cin>>a;
    if(a=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    
}

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

int par[MAX_N];
int ranks[MAX_N];
int g;

void init(int n){
  for(int i = 0; i < n; i++) par[i] = i, ranks[i] = 0;
}

int find(int x){
  if(par[x] == x){
    return x;
  } else{
    int r = find(par[x]);
    return par[x] = r;
  }
}

void unite(int x, int y){
  x = find(x); y = find(y);
  if (x == y) return;
  if (ranks[x] < ranks[y]) swap(x, y);
  if (ranks[x] == ranks[y]) ranks[x]++;
  par[y] = x;
  g--;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  g = n;
  init(n);
  rep(i, m){
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    if(!same(a,b)) unite(a, b);
  }
  cout << g << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int W, H, C;
int gcd(int n, int m){
    if(m==0) return n;
    return gcd(m, n%m);
}
int main(){
    cin >> W >> H >> C;
    if(W<H) swap(W, H);
    int GCD = gcd(W, H);
    cout << (W/GCD)*(H/GCD) * C << endl;
     
    return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
string s;
long long int hoge(int a, int b, long long int c){
    //a index of s
    //b digit
    //c current sum
    if(a==s.size())return c;
    if(a==0) return hoge(1,1,(s[a]-'0'));
    return hoge(a+1, b+1, c+(s[a]-'0')*((long long int)(pow(10, b))))+hoge(a+1,1, c+(s[a]-'0'));
}
 
int main(){
    cin>>s;
    reverse(s.begin(), s.end());
    cout<<hoge(0,0,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,m,a[101][101];
  while(cin>>n>>m,n){
    r(i,n)r(j,n)a[i][j]=(i==j)?0:1e9;
    while(m--){
      int t,q,w,e;
      cin>>t;
      if(t){
        cin>>q>>w>>e;
        if(a[--q][--w]>e){
          a[q][w]=a[w][q]=e;
          r(i,n)r(j,n)
            a[i][j]=min(a[i][j],min(a[i][q]+a[q][w]+a[w][j],a[j][q]+a[q][w]+a[w][i]));
        }
      }
      else{
        cin>>q>>w;
        if(a[--q][--w]!=1e9)cout<<a[q][w]<<endl;
        else cout<<(-1)<<endl;
      }
    }
  }
}

Measured memory_bytes: 3056
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  vector<int> B(N);
  REP(i,N) B[i] = A[i];

  sort(ALL(B));
  reverse(ALL(B));
  REP(i,N){
    if(A.at(i)!=B.at(0)){
      cout << B.at(0) << endl;
    }else{
      cout << B.at(1) << endl;
    }
  }
}

Measured memory_bytes: 3200
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << 800 * n - (n / 15) * 200 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N, M, T[100], P[100], X[100], sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;
    for (int i = 0; i < M; i++) cin >> P[i] >> X[i];
    for (int i = 0; i < M; i++) cout << sum - T[P[i]-1] + X[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define N_MAX 1000000

int N;

int input(){
    cin >> N;
    return 0;
}

// int solve(){
//     long long count_total = 0;
//     // long long memo[N_MAX];
//     // memo[1]=1;
//     for (int c=1;c<N;c++){
//         // N-cの約数の数を求める
//         int count=0; 
//         for (int a=1;a<=N-c/2+1;a++){
//             if ((N-c)%a==0){
//                 count++;
//             }
//         }
//         count

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

int solve(){
    int count = 0;
    for (int a=1;a<=N-1;a++){
        count += (N-1)/a;
    }
    cout << count << endl;
    return 0;
}

int main(){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
    long long int N,i,j,x;
    scanf("%lld",&N);
    char s[1000000],a[1000000];
    scanf("%s",s);
    a[0]=s[0];
    for(i=1,j=1; s[j]!='\0'; j++)
    {
        if(a[i-1]==s[j])
        {
            continue;
        }
        else
        {
            a[i]=s[j];
            i++;
        }
    }
    x=strlen(a);
    printf("%d",x);
    for(i=0; i<x; i++);
    {
        a[i]='\0';
    }
    return 0;
}


Measured memory_bytes: 384
/*===============================================================
*  Filename：D.cpp
*  Author：zhuyutian
*  Date：2018年01月28日
================================================================*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100005;

int n,m;
struct Edge
{
	int to,d;
	Edge(int b = 0,int c = 0):to(b),d(c){}
};
vector<Edge> v[maxn * 2];
int vis[maxn * 2],p[maxn * 2];
bool ok;

void dfs(int x,int pos)
{
	if(vis[x]) 
	{
		if(pos != p[x]) 
			ok = false;
		return;
	}
	vis[x] = 1;
	p[x] = pos;
	for(int i = 0; i < v[x].size() && ok; i++)
		dfs(v[x][i].to,pos + v[x][i].d);
}

int main()
{
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    scanf("%d%d",&n,&m);
	for(int i = 0; i < m; i++) 
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		v[a].push_back(Edge(b,c));
		v[b].push_back(Edge(a,-c));
	}
	ok = true;
	for(int i = 1; i <= n && ok; i++)
	{
		if(vis[i]) continue;
		dfs(i,0);
	}	
	puts(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 14720
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,t,q,u,w,y,r;
int ret=0;
int a[100],b[100],c[100],d[100],v[100];
void dfs(int i,int x){
    v[i]=x;
    if(i==n){
        int ans=0;
        for(int j=0;j<q;j++)
            if(v[b[j]]-v[a[j]]==c[j]) ans+=d[j];
        ret=max(ret,ans);
        return;
    }
    for(int j=x;j<=m;j++)
        dfs(i+1,j);
}
int main()
{
    cin>>n>>m>>q;
    for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
    for(int i=1;i<=m;i++)
        dfs(1,i);
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 3572
n = int(input())

sit = input().split()

T = float(sit[0])
A = float(sit[1])
sc = []
D = []
i = 0
data = input().split()

while i < n:
  D.append(float(data[i]))
  sc.append(T - D[i] * 0.006)
  i += 1
i = 0
res = []
while i < n:
  res.append(abs((A-sc[i])))
  i += 1
mn = min(res)
ans = res.index(mn)


print(ans+1)

  



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

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

  for(int i = 1; i < 4;i ++){
    if(key.at(i-1) == key.at(i)  ){
      cout <<"Bad" << endl;
      return 0;
    }
  }
    cout <<"Good" << endl;
  
  return 0; 
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool chmin (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<
      tuple<long long, long long, long long>
    > shp(n);
  for (int i = 0; i < n; i++) {
    long long h, p;
    cin >> h >> p;
    shp[i] = make_tuple(h + p, h, p);
  }
  sort(shp.begin(), shp.end());
  shp.insert(shp.begin(), make_tuple(0, 0, 0));
  constexpr long long inf = 1LL << 60;
  vector<long long> dp(n + 1, inf);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j >= 0; j--) if (dp[j - 1] <= get<1>(shp[i])) {
      chmin(dp[j], dp[j - 1] + get<2>(shp[i]));
    }
  }
  for (int i = 0; i <= n; i++) {
    if (dp[i] == inf) {
      cout << i - 1 << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,K;
  cin >> N >> K;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  int cnt = 1;
  int ans = 0;
  while(N >cnt) {
    cnt += K-1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640