akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

double esp = 1e-8;

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

  ll X;
  cin >> X;
  ll ans = 0;
  double tmp = 100.0;
  while (1) {
    ans++;
    tmp *= 1.01;
    tmp += esp;
    ll l_tmp = (ll) tmp;
    if (l_tmp >= X) break;
    tmp = (double) l_tmp;
  }


  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int n,x;
    cin >> n >> x;
    int count = 0;

    int ans = 1;

    rep(i,n){
        int a;
        cin >> a;
        count += a;
        if(count<=x)ans++;
    }

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


Measured memory_bytes: 256
#define MOD 1000000007;
#define input ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll long long

#include <bits/stdc++.h>

using namespace std;
const int N = 3e5 + 5;
set<int> st[N + 1];

int main() {
    map<ll, ll> mp;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mp[x]++;
    }

    ll ans = 0;
    for (auto it = mp.rbegin(); it != mp.rend(); it++) {
        if (it->second >= 4) {
            if (ans == 0) {
                cout << it->first * it->first;
                return 0;
            } else {
                cout << ans * it->first;
                return 0;
            }
        } else if (it->second >= 2) {
            if (ans == 0)
                ans = it->first;
            else {
                cout << it->first * ans;
                return 0;
            }

        }

    }
    cout<<0;

}

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

const int mod = 998244353;

int pow(int a, int n) {
  if (a == 0) return  0;
  int ret = 1;
  for (int i = 0; i < n; i++) {
    ret = 1LL * ret * a % mod;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(n + 1);
  for (int& x : a) cin >> x, cnt[x]++;

  if (a[0] || cnt[0] != 1) return cout << 0 << endl, 0;

  int ma = *max_element(a.begin(), a.end());
  int ans = 1;
  for (int i = 0; i < ma; i++) {
    ans = 1LL * ans * pow(cnt[i], cnt[i + 1]) % mod;
  }
  cout << ans << endl;
}


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

#define rep(i, n) for (Int i = 0; i < (Int)n; i++)
#define rep2(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rep3(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

vector<pair<Int, Int>> G[100001];

vector<Int> dijkstra(vector<pair<Int, Int>> G[], Int n, Int s) {
    vector<Int> dist(n, INF);
    priority_queue<pair<Int, Int>, vector<pair<Int, Int>>, greater<pair<Int, Int>>> q;
    q.push({0, s});
    dist[s] = 0;
    while (not q.empty()) {
        pair<Int, Int> p = q.top();
        q.pop();
        Int cur = p.se;
        if (dist[cur] < p.fi) continue;
        rep(i, G[cur].size()) {
            Int to = G[cur][i].fi;
            Int cost = G[cur][i].se;
            if (dist[to] > dist[cur] + cost) {
                dist[to] = dist[cur] + cost;
                q.push({dist[to], to});
            }
        }
    }
    return dist;
}

int main() {
    Int n;
    cin >> n;
    rep(i, n - 1) {
        Int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
    Int q, k;
    cin >> q >> k;
    k--;
    vector<Int> d = dijkstra(G, n, k);
    // rep(i, n) dump(d[i]);
    rep(i, q) {
        Int x, y;
        cin >> x >> y;
        x--, y--;
        dump(d[x] + d[y]);
    }
    return 0;
}

Measured memory_bytes: 11120
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        String pic[]=new String[h];
        for(int i=0;i<h;i++){
            pic[i]=sc.next();
        }
        for(int i=0;i<h;i++){
            for(int k=0;k<2;k++){
                System.out.println(pic[i]);
            }
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

struct Unionfind {
	vector<int> parent;

	Unionfind(int N) {
		parent = vector<int>(N, -1);
	}

	int root(int x) { //親の番号を検索する
		if (parent[x] < 0) return x;
		return parent[x] = root(parent[x]);
	}

	int size(int x) { //自分のグループの大きさを返す
		return -parent[root(x)];
	}

	bool unite(int x, int y) { //XとYを同じグループにする
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (size(x) < size(y)) swap(x, y);
		parent[x] += parent[y];
		parent[y] = x;
		return true;
	}
	bool same(int x, int y) {
		if (root(x) == root(y)) return true;
		return false;
	}
};

int main() {
	int n,m;
	cin >> n >> m;
	Unionfind uni(n);

	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		uni.unite(x, y);
	}

	int ans = 0;
	rep(i, n) {
		ans = max(ans, uni.size(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 4048
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        int N, K;
        string[] str = Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        K = int.Parse(str[1]);
        str = Console.ReadLine().Split(' ');
        char[] p = new char[str.Length];
        for (int i = 0; i < str.Length; i++)
            p[i] = str[i][0];
        for (int i = N; ; i++)
        {
            string d = i.ToString();
            bool t = true;
            for(int j = 0; j < d.Length; j++)
            {
                for (int k = 0;k < p.Length; k++)
                {
                    if (d[j]==p[k])
                    {
                        t = false;
                        break;
                    }
                }
                if (!t)
                    break;
            }
            if (t)
            {
                Console.WriteLine(i);
                break;
            }
        }
    }
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << "+" << endl;
    else if (a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)

template<int MOD> struct MInt {
  long long val;
  MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  bool operator!=(const MInt& n) { return val != n.val; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
const int MOD = 1e9+7;
using mint = MInt<MOD>;
using vi = vector<mint>;
template<class T>using vv = vector<vector<T>>;

vv<char> a;
vv<pair<mint,int>> dp;
int H, W;
mint dfs(int i, int j) {
  if (i >= H || j >= W) return 0;
  if (dp[i][j].second != 1)  return dp[i][j].first;
  if (a[i][j] == '#')   return 0;
  if (i+1 == H && j+1 == W) return 1;
  dp[i][j] = make_pair(dfs(i+1, j) + dfs(i, j+1), 0);
  return dp[i][j].first;
}
int main() {
  in(H); in(W);

  dp.resize(H, vector<pair<mint,int>>(W, make_pair(0, 1)));
  a.resize(H, vector<char>(W));
  rep(i, H) rep(j, W) {
    cin >> a[i][j];
  }

  cout << dfs(0, 0) << endl;
  return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



vector<ll> value; // ノードの値を持つ配列
ll N;             // 葉の数

void update(ll i, ll x) {
	// i 番目の葉の値を x に変える
	i += N - 1; // i 番目の葉のノード番号
	value[i] = x;
	while (i > 0) {
		i = (i - 1) / 2; // ノード i の親ノードの番号に変える
		value[i] = min(value[i * 2 + 1],
			value[i * 2 + 2]); // 左右の子の min を計算しなおす
	}
}

ll query(ll a, ll b, ll k, ll l, ll r) {
	// [a, b) の区間に対するクエリについて
	// ノード k （区間 [l, r) 担当）が答える
	if (r <= a || b <= l) return INFL; // 区間が被らない場合は INF を返す
	if (a <= l && r <= b)
		return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
						 // に完全に含まれる
	else {
		ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
		ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
		return min(c1, c2); // 左右の子の値の min を取る
	}
}

int main() {

	ll n, m;
	cin >> n >> m;
	N = 1;
	while (N < n) N *= 2; // 葉の数を計算（n以上の最小の2冪数）

	value = vector<ll>(2 * N - 1, INFL);



	vector<pair<ll, pair<ll, ll>>> v;

	REP(i, m) {
		int l, r, c;
		cin >> l >> r >> c; 
		l--; r--;
		v.push_back({ l,{r,c} });
	}
	sort(ALL(v));

	update(0, 0);

	REP(i, m) {
		ll a = query(v[i].second.first, v[i].second.first + 1, 0, 0, N);
		ll b = query(v[i].first, v[i].second.first, 0, 0, N) + v[i].second.second;
		//cout << a << ' ' << b << endl;
		if (b < a) {
			update(v[i].second.first, b);
		}
		REP(i, n) {
			//cout << query(i,i+1,0,0,N) << ' ';
		}
		//cout << endl;
	}
	if (query(n-1,n,0,0,N) == INFL) {
		cout << -1 << endl;
	}
	else cout << query(n - 1, n, 0, 0, N) << endl;



}

Measured memory_bytes: 6644
#include <iostream>
#include <string>
#include <algorithm>
#define int long long int

using namespace std;

signed main(){

	int N, i, j, k;
	cin >> N;

	string S[100000];
    int march[5] = {};
	
	for(i = 0; i < N; i++){
		cin >> S[i];

        if(S[i][0] == 'M'){
            march[0] = march[0] + 1;
        }else if(S[i][0] == 'A'){
            march[1] = march[1] + 1;
        }else if(S[i][0] == 'R'){
            march[2] = march[2] + 1;
        }else if(S[i][0] == 'C'){
            march[3] = march[3] + 1;
        }else if(S[i][0] == 'H'){
            march[4] = march[4] + 1;
        }

	}

    int ans = 0;

    for(i = 0; i < 3; i++){
        for(j = i + 1; j < 4; j++){
            for(k = j + 1; k < 5; k++){
                ans = ans + march[i] * march[j] * march[k];
            }
        }
    }

    cout << ans << endl;
	


	return 0;



}

Measured memory_bytes: 6144
n,m=map(int,input().split())
#1とnがつながっているときのa,bの最短距離
def dist(a,b):
  return min(abs(a-b),n-abs(a-b))

a,b = n,1
S=set()
for i in range(m):
  distab = dist(a,b)
  #distabがnの半分のとき
  if 2*distab == n or distab in S:
    a -= 1
  print(a,b)
  S.add(distab)
  a -= 1
  b += 1

Measured memory_bytes: 17516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////
ll memo[1000000];
ll kai(ll n){
    if(memo[n]!=0){
        return memo[n];
    }
    if(n==0){
        return memo[n]=1;
    }
    return memo[n]=(kai(n-1)*n)%i_7;
}
int main(){
    ll n,m;cin>>n>>m;
    if(abs(n-m)>=2){
        cout<<0<<endl;
        return 0;
    }
    if(n<m){
        swap(n,m);
    }
    ll ans;
    if(n==m){
        ans=(2*kai(n)*kai(n))%i_7;
    }else{
        ans=(kai(n)*kai(n-1))%i_7;
    }
    cout<<ans%i_7<<endl;
    
    return 0;
}


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

int main()
{
    // input
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
        cin >> l.at(i);

    // choose three sticks and judge
    int count = 0;
    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i + 1; j < n - 1; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                int p = l.at(i);
                int q = l.at(j);
                int r = l.at(k);
                if (p == q || q == r || p == r)
                    continue;
                else if (p + q <= r || q + r <= p || p + r <= q)
                    continue;
                else
                    count++;
            }
        }
    }

    // output
    cout << count << endl;
    return 0;
}

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

int N, S;
void solve(){
    while (cin >> N && N > 0){
        int sum = 0;
        int min = 1000000;
        int max = -1;
        for (int i = 0; i < N; i++){
            cin >> S;
            sum += S;
            if (min > S) min = S;
            if (max < S) max = S;
        }
        cout << (sum - max - min)/(N-2) << endl;
    }
}



int main(){
    solve();
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int h,w,n,i=0,j,p;
    string s;
    pair<pair<string,int>,int> a[1000];
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> s >> p;
        a[i]=make_pair(make_pair(s,-p),i+1);
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        cout << a[i].second << endl;
    }
    return 0;
}


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

int main() {
  // ここにプログラムを追記
  int number;
  cin >> number;
  //number = 000;
  int s1 = number / 100;
  int s2 = (number % 100) / 10;
  int s3 = (number % 10) / 1;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define max(a,b) (a>b?a:b)
int main()
{
	int a, b;
  cin>>a>>b;
  int temp;
  	if(a>b)
    {
      temp = a;
      a--;
    }
  else
  {
    temp = b;
    b--;
  }
  	temp += max(a,b);
  cout<<temp;
	return 0;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	vec := make([]int, 0, 3)
	for i := 0; i < 3; i++ {
		vec = append(vec, nextInt(sc))
	}
	sort.Ints(vec)
	fmt.Println(vec[0], vec[1], vec[2])
}



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

int main()
{
	int n,k;
	cin >> n;
	string s; 
	cin >>s >>k;
	char s0=s[k-1];
	for (int i=0;i<n;i++){
    	if(s[i]!=s0){
        	cout <<"*";
        }else {
        	cout << s[i];
        }
    }
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int []n=new int[3];
int m[]=new int[]{5,5,7};
for(int i=0;i<3;i++){
n[i]=sc.nextInt();
}
Arrays.sort(n);
boolean b=false;
for(int i=0;i<3;i++){
if(n[i]!=m[i]){
b=true;
break;
}
}
if(b)
        System.out.println("NO");
else System.out.println("YES");
}}

Measured memory_bytes: 21332
n,d,a=list(map(int,input().split()))
e=[]
for i in range(n):
  inp=list(map(int,input().split()))
  inp[1]=(inp[1]-1)//a+1
  e.append(inp)
e.sort()
sd=[0 for i in range(n)]
s=0
mx=0
i=0
j=0
while True:
  while e[i][1]+s<=mx:
    i+=1
    if i>=n:
      break
    s+=sd[i]
  while i<n and j<n and e[j][0]<=e[i][0]+2*d:
    j+=1
  if j<n:
      sd[j]+=e[i][1]+s-mx
      mx=e[i][1]+s
  else:
    if i>=n:
      break
    mx=e[i][1]+s
    
print(mx)

Measured memory_bytes: 53632
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll k,n; cin>>k>>n;
    ll arr[n+2];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    ll mx=INT_MAX;
    for(int i=2;i<=n;i++){
        mx=min(mx,k-arr[i]+arr[i-1]);
    }
    mx=min(mx,arr[n]-arr[1]);
    cout<<mx<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

const int MOD = 1'000'000'007;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll h, w;
    cin >> h >> w;
    char ch;
    vector<vector<int>> v(h + 2, vector<int> (w + 2));
    v[1][1] = 1;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            cin >> ch;
            if (ch == '.')
            {
                v[i + 1][j] += v[i][j];
                v[i + 1][j] %= MOD;
                v[i][j + 1] += v[i][j];
                v[i][j + 1] %= MOD;
            }
        }
    }
    cout << v[h][w];
    return 0;
}


Measured memory_bytes: 4224
/*
	
	
	
	?????°??°??????????????°???????????????????????????
*/

#include<stdio.h>

typedef struct DATA Data;
struct DATA{
	int time;	//?????????
	int pc;	//PC????????????
	int student;	//??????????????????
	int s;	//?????°????????????1, ?????°??¢????????????0???
};

int main(int argc, char *argv){
	while( Main() == 0 );
	return 0;
}

int Main(){
	int N = 0, M = 0, r = 0, q = 0, ts = 0, te = 0, m = 0, time = 0, bt = 0, pcount = 0, i = 0, j = 0;	//PC?????°??°???????????°????????¨?¨??????°???????????°????????????????§???¨????????????????????????????????????????????????????????¨???????????????????????°??????????????????(??¬????????????????????°???????????????????????????-1)????????°??????????????????PC?????°??°???
	if( scanf("%d %d", &N, &M) != 2 ){ return -1; }
	if( N == 0 || M == 0 ){ return 1; }
	if( scanf("%d", &r) != 1 ){ return -1; }
	char pt[N];
	for( i = 0; i < N; i++ ){ pt[i] = 0; }
	Data data[r];
	//?????¨?¨?????????\??????
	for( i = 0; i < r; i++ ){
		if( scanf("%d %d %d %d", &data[i].time, &data[i].pc, &data[i].student, &data[i].s) != 4 ){ return -1; }
	}
	if( scanf("%d", &q) != 1 ){ return -1; }
	//???????????\?????¨?????????
	for( i = 0; i < q; i++ ){
		//????????????
		time = 0;
		bt = -1;
		pcount = 0;
		for( j = 0; j < N; j++ ){ pt[j] = 0; }
		//???????????\??????
		if( scanf("%d %d %d", &ts, &te, &m) != 3 ){ return -1; }
		//?????¨?¨??????¨?????§??????
		for( j = 0; j < r; j++ ){
			//????±??????\????????????????????????
			if( data[j].student != m ){ continue; }
			//?????°???????????????????????????
			if( data[j].s == 1 ){
				pcount++;
				//??¢?????????PC??§?????°?????????????????????????????????
				if( pcount > 1 ){ continue; }
				//??¬???????§??????????bt?????¬???????§?????????????????????????????§?????????????????????????
				if( data[j].time < ts ){
					bt = ts;
				}else if( data[j].time < te ){
					bt = data[j].time;
				}else{
					bt = -1;
//					j = r;	//??¬????????????????????°??????????????????????????§????????¨?¨?????????§?????????????????????
				}
			}
			//?????°??¢??????????????¨???????????????
			if( data[j].s == 0 ){
				pcount--;
				if( pcount > 0 ){ continue; }
				if( bt == -1 ){ continue; }	//?????????????????°????????????????????????
				//??¬???????§?????????????????????????????????¬?????????????????????????????¬????????????????????¬????????????????????§????????????????????????
				if( data[j].time >= te ){
					time += te - bt;
					bt = -1;
					break;	//????????\???????????¨?¨???????????±????????????¨???????????±?????????????????????
				}else if( data[j].time > ts ){
					time += data[j].time - bt;
					bt = -1;
				}else{
					bt = -1;
				}
			}
		}
		printf("%d\n", time);
	}
	return 0;
}

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

#define nl '\n'

#define PI 3.14159265

using namespace std;

int a, b, c;

int main(){

    cin >> a >> b >> c;

    while(a*c > b){
        c--;
    }

    cout << c;



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int d , t, s;
    cin >> d >> t >> s;

    if (d <= s*t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3636
N, K = list(map(int, input().split()))
t = []
for i in range(1, N+1):
  c = 0
  x = i
  while x<K:
    x <<= 1
    c += 1
  t.append(c)
tx = max(t)
print(1.0 * sum([1<<(tx-ti) for ti in t]) / (1<<tx) / N)

Measured memory_bytes: 4632
import math


class LR:
    def __init__(self, l, r):
        self.left = l
        self.right = r


def is_prime(num):
    if (num < 2):
        return False
    elif(num == 2):
        return True
    elif (num % 2 == 0):
        return False
    sqrt_num = int(math.sqrt(num))
    for i in range(3, sqrt_num+1):
        if i % 2 == 0:
            continue
        if (num % i == 0):
            return False
    return True


def generate_prime_dict():
    prime_dict = {}
    for num in range(1, 100001):
        if is_prime(num):
            prime_dict[num] = 1
    return prime_dict


prime_dict = generate_prime_dict()

like_2017_dict = {}

cnt = 0
for n in range(100001):
    if n in prime_dict and ((n+1)/2) in prime_dict:
        cnt += 1
    like_2017_dict[n] = cnt


Q = int(input())
lrs = []
for _ in range(Q):
    l, r = map(int, input().split())
    lrs.append(LR(l, r))

for lr in lrs:
    print(like_2017_dict[lr.right] - like_2017_dict[lr.left-1])


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

int n;
int syakin = 100000;

void kiri()
{
	if(syakin%1000 > 0){
		syakin = syakin/1000*1000+1000;
	}
}

int risi(int n)
{
	if(n == 0){
		return syakin;
	}else{
		syakin = static_cast<int>(static_cast<double>(syakin*1.05));
		kiri();
		risi(n-1);
	}
}

int main()
{
	cin >> n;
	cout << risi(n) << endl;
	return 0;
}

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

const ll Mod = 1000000007;

ll n, k;
int a[2020];

int main(){
	scanf("%d%d", &n, &k);
	rep(i, n) scanf("%d", &a[i]);
	int sum = 0;
	int add1 = k * (k-1) / 2 % Mod, add2 = k * (k+1) / 2 % Mod;
	rep(i, n){
		rep(j, i){
			if(a[j] < a[i]) sum += add1;
			if(a[j] > a[i]) sum += add2;
			sum %= Mod;
		}
	} 
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define EPS 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;

#define MAX 1000
#define VMAX 10000

int main(){
  int n,w[1000],ans=0,s=INT_MAX;
  cin>>n;
  rep(i,n){
    scanf("%d",&w[i]);
    s=min(s,w[i]);
  }
  bool V[VMAX]={};
  int B[MAX]={},T[VMAX]={};
  rep(i,n)B[i] = w[i];
  sort(B,B+n);
  rep(i,n)T[B[i]]=i;
  rep(i,n){
    if(V[i]) continue;
    int cur=i,S=0,m=VMAX,an=0;
    do{
      V[cur]=true;
      an++;
      int v=w[cur];
      m=min(m,v);
      S+=v;
      cur = T[v];
    }while(!V[cur]);
    ans+=min(S+(an-2)*m,m+S+(an+1)*s);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
#define gog pair<int,string>
//#define cin fin
//#define cout fout
using namespace std;

//ifstream fin("joc7.in");
//ofstream fout("joc7.out");

const int nmax=1e3+5;
const int mod=1e9+7;
const int mod1=998244353;

int n,x,l[105],ans;

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
	cin >> n >> x;
	for(int i=1;i<=n;i++){
        cin >> l[i];
        l[i]=l[i-1]+l[i];
        if(l[i]<=x) ans++;
	}
	rc(++ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
 
using namespace std;
 
int main() {
 
    int a[5];
    int kari;
    char d;
     
    while (cin >> a[0] >> d >> a[1] >> d >> a[2] >> d >> a[3] >> d >> a[4]) {
        for (int i = 4; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                if (a[j] > a[j+1]) {
                    kari = a[j];
                    a[j] = a[j+1];
                    a[j+1] = kari;
                }
            }
        }
        if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3] || a[3] == a[4]) {
            if ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]) || (a[2] == a[3] && a[3] == a[4])) {
                if (((a[0] == a[1] && a[1] == a[2]) && (a[3] == a[4])) || ((a[0] == a[1]) && (a[2] == a[3] && a[3] == a[4]))) {
                    cout << "full house" << endl;
                } else if ((a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) || (a[1] == a[2] && a[2] == a[3] && a[3] == a[4])){
                    cout << "four card" << endl;
                }else {
                    cout << "three card" << endl;
                }
            } else if ((a[0] == a[1] && a[2] == a[3]) || (a[0] == a[1] && a[3] == a[4]) || (a[1] == a[2] && a[3] == a[4])) {
                if ((a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) || (a[1] == a[2] && a[2] == a[3] && a[3] == a[4])) {
                    cout << "four card" << endl;
                } else {
                    cout << "two pair" << endl;
                }
            } else {
                cout << "one pair" << endl;
            }
        } else if ((a[1] == a[0] + 1 && a[2] == a[1] + 1 && a[3] == a[2] + 1 && a[4] == a[3] + 1) || (a[0]  == 1 && a[1] == 10 && a[2] == a[1] + 1 && a[3] == a[2] + 1 && a[4] == a[3] + 1)){
            cout << "straight" << endl;
        } else {
            cout << "null" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//-------------------------------------------------------
int Odd[100001];
long Even[100001]; 
void Calc(){
	int N = rei() / 2;;
	for(int i=0;i<N;i++){
		Odd[rei()]++;
		Even[rei()]++;
	}
	int maxo = 0;
	for(int i=1;i<=100000;i++){
		if(Odd[maxo] < Odd[i]){
			maxo = i;
		}
	}
	int maxo2 = 0;
	for(int i=1;i<=100000;i++){
		if(i != maxo && Odd[maxo2] < Odd[i]){
			maxo2 = i;
		}
	}
	int maxe = 0;
	for(int i=1;i<=100000;i++){
		if(Even[maxe] < Even[i]){
			maxe = i;
		}
	}
	int maxe2 = 0;
	for(int i=1;i<=100000;i++){
		if(i != maxe && Even[maxe2] < Even[i]){
			maxe2 = i;
		}
	}
	if(maxo == maxe){
		int ans = min(N-Odd[maxo2]+N-Even[maxe],N-Odd[maxo]+N-Even[maxe2]);
		cout << ans << endl;
	}
	else{
		int ans = N-Odd[maxo]+N-Even[maxe];
		cout << ans << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main 
{
	
	static long gcd(long a, long b) 
	{ 
	    if (a == 0) 
	        return b; 
	    return gcd(b % a, a); 
	} 
	
	static int n;
	static long[] a, fl, fr;
		
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new long[n];
		fl = new long[n];
		fr = new long[n];
		
		long curg = 0;
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextLong();
			curg = gcd(curg,a[i]);
			fl[i] = curg;
		}
		
		curg = 0;
		for(int i = n-1; i >= 0; i--)
		{
			curg = gcd(curg,a[i]);
			fr[i] = curg;
		}
		
		long max = 0;
		for(int i = 0; i < n; i++)
		{
			long l = 0;
			long r = 0;
			if(i > 0)l = fl[i-1];
			if(i < n-1)r = fr[i+1];
			max = Math.max(max, gcd(l,r));
//			System.out.println("i " + i + ", l: " + l + ", r: " + r + ", curg " + gcd(l,r));
		}
		System.out.println(max);

	}

}


Measured memory_bytes: 63064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi color(9);
    rep(i, n) {
        int a;
        cin >> a;
        if(a >= 3200) {
            color[8]++;
        } else {
            color[a/400]++;
        }
    }
    int cnt = 0;
    rep(i, 8) {
        cnt += color[i] != 0;
    }
    cout << max(1, cnt) << ' ' << cnt+color[8] << endl;
}

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

int main() {
    vector<int> vec(3);
  	for (int i = 0; i < 3; i++) {
    	cin >> vec.at(i);  
    }
  	sort(vec.begin(), vec.end());
  	cout << vec.at(2) * 10 + vec.at(1) + vec.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    int main() {
    
     while(true){
     int x,y;
     cin >> x >> y;
     
     if(x==0 && y==0){
     	return 0;
      
      } else{
     	 if(x>=y)	printf("%d %d\n",y,x);
     	 else 	    printf("%d %d\n",x,y);
      }
      
     }
     return 0;
    }


Measured memory_bytes: 3136
package main

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

func main() {

	for {
		n := ScanedLinetoIntSlice()
		//H, W
		H := n[0]
		W := n[1]

		//var H, W int

		//fmt.Scanln(&H, &W)

		if H == 0 && W == 0 {
			break
		}
		for i := 0; i < H; i++ {
			if i == 0 || i == H-1 {
				fmt.Println(strings.Repeat("#", W))
			} else {
				fmt.Println("#" + strings.Repeat(".", W-2) + "#")
			}
		}
		fmt.Printf("\n")
	}

}

func ScanedLinetoIntSlice() []int {

	//var sc = bufio.NewScanner(os.Stdin)
	//sc.Scan()
	line := readLine()

	words := strings.Fields(line)

	var numbers []int

	for _, v := range words {
		number, _ := strconv.Atoi(v)
		numbers = append(numbers, number)
	}

	return numbers
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}



Measured memory_bytes: 5728
#include<stdio.h>

int yasuna(int,int);

int AGIRI[101][101];
int KAZUHO[101];

int main(){
  int kill,me,baby,i,j,k;
  scanf("%d",&kill);
  for(me=0;me<kill;me++)scanf("%d%d",&KAZUHO[me],&KAZUHO[me+1]);
  for(i=0;i<101;i++)for(j=0;j<101;j++)AGIRI[i][j]=-1;
  for(me=0;me<kill;me++)
    for(baby=1;baby+me<=kill;baby++)
      yasuna(baby,baby+me);
  printf("%d\n",AGIRI[1][kill]);
  return 0;
}
int yasuna(int i,int j){
  int k,f,a;
  if(i==j){
    AGIRI[i][j]=0;
    return 0;
  }
  for(k=i;k<j;k++){
    if(k==i)f=AGIRI[i][k]+AGIRI[k+1][j]+KAZUHO[i-1]*KAZUHO[k]*KAZUHO[j];
    else{
      a=AGIRI[i][k]+AGIRI[k+1][j]+KAZUHO[i-1]*KAZUHO[k]*KAZUHO[j];
      f=f<a?f:a;
    }
  }
  AGIRI[i][j]=f;
}



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

using namespace std;

typedef long long int ll;

const int N = 1e3 + 5;

vector < vector < ll > > g (N, vector < ll > (3));
vector < vector < pair < ll, long double > > > adj (N);
vector < long double > d (N, 1e17);

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

  cout << fixed << setprecision (15);

  ll xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;
  ll n;
  cin >> n;
  g[1] = {xs, ys, 0};
  for (int i = 2; i <= n + 1; i++) cin >> g[i][0] >> g[i][1] >> g[i][2];
  g[n + 2] = {xt, yt, 0};
  n += 2;

  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      long double dis = max (sqrt ((g[j][0] - g[i][0]) * (g[j][0] - g[i][0]) + (g[j][1] - g[i][1]) * (g[j][1] - g[i][1])) - (g[i][2] + g[j][2]), (double)0);
      adj[i].push_back({j, dis});
      adj[j].push_back({i, dis});
    }
  }

  d[1] = 0;
  priority_queue < pair < long double, int >, vector < pair < long double, int > >, greater < pair < long double, int > > > q;
  q.push ({0, 1});
  while (!q.empty()) {
    int u = q.top().second;
    long double d_u = q.top().first;
    q.pop();
    if (d_u != d[u]) continue;

    for (auto edge : adj[u]) {
      int to = edge.first;
      long double len = edge.second;
      if (d[to] > d[u] + len) {
        d[to] = d[u] + len;
        q.push ({d[to], to});
      }
    }
  }

  cout << d[n] << '\n';
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

vector<bool> is_prime;
vector<bool> is_prime_small;

ll res[10000];

// 約数の列挙O(√n)
ll divisor(ll n) {
  ll ret = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res[ret++] = (i);
      if (i != n / i) {
        res[ret++] = (n / i);
      }
    }
  }
  return ret;
}

// a > b
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

void solve(long long N, std::vector<long long> A) {
  is_prime.resize(0);
  for (int i = 0; i <= 1e6; i++) {
    is_prime.push_back(true);
  }
  is_prime[0] = is_prime[1] = false;
  ll n = divisor(A[0]);
  REP(k, n) {
    ll i = res[k];
    if (is_prime[i]) {
      for (int j = i; j <= 1e6; j += i) {
        is_prime[j] = false;
      }
    }
  }
  ll count = 0;
  FOR(j, 1, N) {
    if (A[j] == 1) {
      continue;
    }
    if (is_prime[A[j]]) {
      ll n = divisor(A[j]);
      REP(k, n) {
        ll i = res[k];
        if (is_prime[i]) {
          for (int j = i; j <= 1e6; j += i) {
            is_prime[j] = false;
          }
        }
      }
    } else {
      count++;
    }
  }
  if (count == 0) {
    cout << "pairwise coprime" << endl;
    return;
  }
  int x = A[0];
  FOR(j, 1, N) {
    if (x > A[j]) {
      x = gcd(x, A[j]);
    } else {
      x = gcd(A[j], x);
    }
  }
  if (x == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 11436
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll x,t;
cin>>x>>t;
cout<<max(x-t,(ll)0)<<endl;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;

const int INF = 1000000010;
const ll MOD = 1000000007;

int main() {FIN
    
    ll n, k, r;
    cin >> n >> k;
    r = k;
    for (int i = 1; i < n; i++)
		r *= (k-1);
	cout << r << "\n";
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int n,w;
    cin>>n>>w;
    vector<ii> v(n);
    for(auto &i:v) cin>>i.fi>>i.se;
    vector<ll> dp(w+1);
    rep(i,n) {
        Repp(j,w,v[i].fi) {
            dp[j]=max(dp[j],dp[j-v[i].fi]+v[i].se);
        } 
    }
    cout<<dp[w];
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int out = 0;
        for(int i = 1; i <= n; i += 2){
            if(f(i) == 8) out++;
        }
        System.out.println(out);
    }

    int f(int n){
        if(n == 1) return 1;
        int ret = 2;
        for(int i = 2; i < Math.sqrt(n); i++){
            if(n % i == 0) ret += 2;
        }
        if(n % Math.sqrt(n) == 0) ret++;
        return ret;
    }


    public static void main(String[] args){
        new Main().solve();
    }
}


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

ll combi(ll a, ll b){
    ll rep=1;
    for(int i=a;i>a-b;i--) rep*=i;
    for(int i=b;i>0;i--) rep/=i;
    return rep;
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> mod[k];
    for(int i=1;i<=n;i++){
        mod[i%k].push_back(i);
    }
    ll ans=0;
    if(k%2==0){
        ans=combi(mod[0].size(),1)+combi(mod[0].size(),2)*6+combi(mod[0].size(),3)*6;
        ans+=combi(mod[k/2].size(),1)+combi(mod[k/2].size(),2)*6+combi(mod[k/2].size(),3)*6;
    }
    else{
        ans=combi(mod[0].size(),1)+combi(mod[0].size(),2)*6+combi(mod[0].size(),3)*6;
    }
    cout << ans << endl;

}

Measured memory_bytes: 8064
#vacation
N = int(input())
dp = [[0] * 3 for _ in range(N)]
for i in range(N):

    h = list(map(int, input().split()))
    if i == 0:
        for p in range(3):
            dp[0][p] = h[p]
        continue
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + h[0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + h[1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + h[2]

print(max(dp[N-1]))
    

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

using namespace std;

int main(void) {
    long int N,c = 0,i,j,k;
    string S;
    cin >> N;
     cin >> S;
     long int r=0,g=0,b=0;
  
    
 
    for (i=0;i<N;++i){
        if(S[i] == 'R'){
            r++;
        }
        if(S[i] == 'G'){
            g++;
        }
        if(S[i] == 'B'){
            b++;
        }
    
    }
    long int ans = r* b *g;
  
    for(i = 0;i<N-2;++i){
          for(int j =i + 1;j<N-1;++j){
              long int k = 2*j - i;
              if(k < N){
              if(S[i]!=S[j] && S[i]!=S[k] && S[j]!=S[k]){
                           ans--;
           }
              }
         
    } 

         
    } 

  cout << ans << "\n"; 
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
 
main()
{
int a,b;
  while(1){
   scanf("%d %d",&a,&b);
   if((a|b)==0)break;
   if(b<a)std::swap(a,b);
   printf("%d %d\n",a,b);
   }
}


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

#define all(a) a.begin(), a.end()

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  double res1 = W*H*0.5;
  int res2 = (2*x == W && 2*y == H) ? 1 : 0;
  cout << fixed << res1 << " " << res2 << "\n";
  return 0;
} 


Measured memory_bytes: 256