akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
const int nx = 2e5 + 1;
vector<ll> graph[200006];
vector<bool> visited(2e5 + 1);
bool check_cycle;
vector<ll> dis(2e5 + 1);
ll tance, from, to;
void dfs(ll root) {
    visited[root] = true;
    for(auto num: graph[root]) {
        if(!visited[num]) {
            ++tance;
            dis[num] = tance;
            dfs(num);
        }
        else {
            check_cycle = true;
            from = root, to = num;
        }
    }
}
int main() {
    ll N, K;
    check_cycle = false, tance = 0, from = -1, to = -1;
    cin >> N >> K;
    ll arr[N + 1];
    for(int i = 1; i  <= N; ++i){
        cin >> arr[i];
        graph[i].pb(arr[i]);
    }
    dfs(1);
    ll ans = to, root = from;
    //cout << ans << " " << root << endl;
    ll curr, idx;
    if(check_cycle) {
        ll cyfir = dis[ans];
        ll cynd = dis[root];
        //cout << cyfir << " " << cynd << endl;
        if(K <= cyfir) {
            idx = 1;
            curr = arr[idx];
            for(int i = 1; i <= K; ++i) {
                idx = curr;
                curr = arr[idx];
            }
        }
        else {
            ll diff = K - cyfir;
            ll md = diff % (cynd - cyfir + 1);
            //cout << md << endl;
            idx = ans;
            curr = arr[idx];
            for(int i = 1; i <= md; ++i) {
                idx = curr;
                curr = arr[idx];
                //cout << idx << " " << curr << endl;
            }
        }
    }
    else {
        idx = 1;
        curr = arr[idx];
        for(int i = 1; i <= K; ++i) {
            idx = curr;
            curr = arr[idx];
        }
    }
    cout << idx << endl;
}


Measured memory_bytes: 26592
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define F(i, n) for(int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 10*100000 + 47;

char S[MAX];
int A[MAX];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    scanf("%s", S);
    FOR(i, 0, n)A[i] = (S[i] - 'A') ^ (i & 1);
    int iter = min(n + n, m);
    int L = 0, R = n -1, cur = n & 1;
    FOR(it, 0, iter)
    {
        if (A[L])
        {
            ++L;
            ++R;
            A[R] = (n & 1) ^ 1;
        }
        else
        {
            A[L] ^= 1;
        }
    }
    if (m > 2 * n && (m & 1) && (n & 1))A[L] ^= 1;
    FOR(i, L, R + 1)
    A[i] ^= (i - L) & 1;
    
    FOR(i, L, R+1)
    printf("%c", 'A' + A[i]);
    printf("\n");
    
    
    
    
    
}



Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll h[110000];
vector<pair<ll,ll>> x,y;
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    ll a,b;

    rep(i,1,n+1)cin>>h[i];
    rep(i,0,m){cin>>a>>b;x.pb(mp(a,b));y.pb(mp(b,a));}
    ll cnt=0,c2=0;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
     rep(i,1,n+1){
        ll st=h[i];
        bool q=true,q2=true;
        while(cnt<m&&q){
            if(x[cnt]F==i){
                if(h[x[cnt]S]>=st){q=false;cnt++;}
                else cnt++;
            }
            else if(x[cnt]F<i)cnt++;
            else break;
        }
        while(c2<m&&q2){
            if(y[c2]F==i){
                if(h[y[c2]S]>=st){q2=false;c2++;}
                else c2++;
            }
            else if(y[c2]F<i)c2++;
            else break;
        }
        if(q&&q2)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7420
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll A,B;
  cin >> A>>B;
  cout << (B%A==0 ? A+B : B-A) << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

exp = 0

def calc_exp(init) :
	point = init
	n_play = 0

	while point < K :
		point *= 2
		n_play += 1

	return 1 / (2 ** n_play)

for i in range(1, N+1) :
	exp += calc_exp(i)

print('{:.10f}'.format(exp / N))

Measured memory_bytes: 3060
import sys

S = str(input())
Smax = len(S)

for i in range(0, Smax, 2) :
  if S[i] == "L" :
    print("No")
    sys.exit()
  else :
    continue

for i in range(1, Smax, 2) :
  if S[i] == "R" :
    print("No")
    sys.exit()
  else :
    continue

print("Yes")

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

using namespace std;

int main() {
	long int a, b, x;
	cin >> a >> b >> x;
	long int ans;

	if (a % x == 0) {
		ans = (b / x) - (a / x) + 1;
	}
	else {
		ans = (b / x) - (a / x);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i=1; ;i++){
            int x = sc.nextInt();
            if(x==0){
                break;
            }
            System.out.printf("Case %d: %d\n",i,x);
        }
    }
}


Measured memory_bytes: 65840
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 H, A;
  cin >> H >> A;
  cout << (H + A - 1) / A << endl;
}


Measured memory_bytes: 256
n = int(input())
x = [0] * n
u = [0] * n
for j in range(n):
  x[j], u[j] = input().split()
  x[j] = float(x[j])
ans = 0.0
for i in range(n):
  if u[i] == 'JPY':
    ans += x[i]
  else:
    ans += x[i] * 380000.0
print(ans)


Measured memory_bytes: 3060
# H - Grid 1
H,W = map(int,input().split())
maze = []
for _ in range(H):
    a = list(input())
    maze.append(a)

# dp[i][j]: 座標 (i, j) に到達できる経路の数
dp = [[0]*(W) for _ in range(H)]

# 初期条件 
# 座標 (0, 0) への経路は 1 通り
dp[0][0] = 1

for h in range(H):
    for w in range(W):
        # スタート位置のときはスルー
        if (h,w) == (0,0):
            continue
        # 壁があるときはスルー
        if maze[h][w] == '#':
            continue
        # 左にマスがあるとき 
        if w > 0:
            dp[h][w] = (dp[h][w] + dp[h][w-1])%(10**9+7)
        # 上にマスがあるとき
        if h > 0:
            dp[h][w] = (dp[h][w] + dp[h-1][w])%(10**9+7)
print(dp[H-1][W-1])

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

int main(){
  int N,K;
  cin >> N >> K;
  
  int cnt = 0;
  vector<int> A(N);
  vector<int> B(200000,0);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    B.at(A.at(i)) ++;
    if(B.at(A.at(i)) == 1){
      cnt ++;
    }
  }
  if(cnt <= K){
    cout << 0 << "\n";
    return 0;
  }
    
  sort(B.begin(),B.end());
  int i_non0 = 0;
  for(int i=0;i<200000;i++){
    if(B.at(i)!=0){
      i_non0 = i;
      break;
    }
  }

  int ans = 0;
  
  for(int i=i_non0;i<i_non0+(cnt-K);i++){
    ans +=B.at(i);
  }
  cout << ans << "\n";
  
}
    
  

Measured memory_bytes: 1792
using System;
using System.Text;
namespace AIZU_Cs_
{
    class Program
    {
        static void Main(string[] args)
        {
            int x,y;
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null) break;
                args = s.Split(' ');
                x = int.Parse(args[0]);
                y = int.Parse(args[1]);
                x += y;
                Console.WriteLine(x.ToString().Length);
            }
        }
    }
}

Measured memory_bytes: 8992
from itertools import combinations_with_replacement as comb_rplc

n, m, q = list(map(int, input().split()))
# reqは[[a1,b1,c1,d1],[a2,b2,c2,d2]……]が入ったリストのリストです
req = [list(map(int, input().split())) for _ in range(q)]

ans = 0
# seqは長さnのタプルです
for seq in comb_rplc(range(1, m + 1), n):
    score = 0
    for a, b, c, d in req:
        # 問題文に書いてある数列のk番目は、インデックスだとk-1になるので注意
        if seq[b - 1] - seq[a - 1] == c:
            score += d
    ans = max(ans, score)

print(ans)


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

int main() {
  string S;
  cin >> S;
  int x = 0, y = 0;
  for (int i = 0, j = 0; i < S.size(); i++) {
    if (S.at(i) == '0' + j) x++;
    else y++;
    j = j ^ 1;
  }
  cout << min(x, y) << "\n";
}

Measured memory_bytes: 512
/*
Program
Written by "Vaibhav" aka 'ZodiacBestro'
In 2017
*/

#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9
#define fast_cin ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair<int,int> pii;

const ll MOD = 1e9+7;
const ll MAXN = 1e6+5;

ll dp[MAXN],dp1[MAXN];

void jo (string s){
	int a = s[0]-48;
	int b = s[1]-48;
	int c = s[2]-48;
	int d = s[3]-48;
	//cout << a << b << c << d << endl;
	string ans ;
	if (a + b + c + d == 7)
	{
		//ans = s[0] + '+' + s[1] + '+' + s[2] + '+' + s[3] + "=7"; 
		ans.pb(s[0]);
		ans.pb('+');
		ans.pb(s[1]);
		ans.pb('+');
		ans.pb(s[2]);
		ans.pb('+');
		ans.pb(s[3]);
		ans.pb('=');
		ans.pb('7');

		//cout << ans << endl;
	}
	else if (a - b + c + d == 7)
	{
		//ans = s[0] + '-' + s[1] + '+' + s[2] + '+' + s[3] + "=7";
		ans.pb(s[0]);
		ans.pb('-');
		ans.pb(s[1]);
		ans.pb('+');
		ans.pb(s[2]);
		ans.pb('+');
		ans.pb(s[3]);
		ans.pb('=');
		ans.pb('7'); 
	}
	else if (a + b - c + d == 7)
	{
		//ans = s[0] + '+' + s[1] + '-' + s[2] + '+' + s[3] + "=7";
		ans.pb(s[0]);
		ans.pb('+');
		ans.pb(s[1]);
		ans.pb('-');
		ans.pb(s[2]);
		ans.pb('+');
		ans.pb(s[3]);
		ans.pb('=');
		ans.pb('7');
	}
	else if (a + b + c - d == 7)
	{
		//ans = s[0] + '+' + s[1] + '+' + s[2] + '-' + s[3] + "=7";
		ans.pb(s[0]);
		ans.pb('+');
		ans.pb(s[1]);
		ans.pb('+');
		ans.pb(s[2]);
		ans.pb('-');
		ans.pb(s[3]);
		ans.pb('=');
		ans.pb('7');
	}
	else if (a - b - c + d == 7)
	{
		//ans = s[0] + '-' + s[1] + '-' + s[2] + '+' + s[3] + "=7";
		ans.pb(s[0]);
		ans.pb('-');
		ans.pb(s[1]);
		ans.pb('-');
		ans.pb(s[2]);
		ans.pb('+');
		ans.pb(s[3]);
		ans.pb('=');
		ans.pb('7');
	}
	else if (a + b - c - d == 7)
	{
		//ans = s[0] + '+' + s[1] + '-' + s[2] + '-' + s[3] + "=7";
		ans.pb(s[0]);
		ans.pb('+');
		ans.pb(s[1]);
		ans.pb('-');
		ans.pb(s[2]);
		ans.pb('-');
		ans.pb(s[3]);
		ans.pb('=');
		ans.pb('7');
	}
	else if (a - b + c - d == 7)
	{
		//ans = s[0] + '-' + s[1] + '+' + s[2] + '-' + s[3] + "=7";
		ans.pb(s[0]);
		ans.pb('-');
		ans.pb(s[1]);
		ans.pb('+');
		ans.pb(s[2]);
		ans.pb('-');
		ans.pb(s[3]);
		ans.pb('=');
		ans.pb('7');
	}
	else if (a - b - c - d == 7)
	{
		//ans = s[0] + '-' + s[1] + '-' + s[2] + '-' + s[3] + "=7";
		ans.pb(s[0]);
		ans.pb('-');
		ans.pb(s[1]);
		ans.pb('-');
		ans.pb(s[2]);
		ans.pb('-');
		ans.pb(s[3]);
		ans.pb('=');
		ans.pb('7');
	}
	cout << ans << endl;
}

int main()
{
	fast_cin; cin.tie(NULL); cin.tie(NULL);
	string n;
	cin >> n;
	jo(n);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stack>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <iterator>
#include <set>
#include <map>
#include <utility>
#include <iomanip>
#include <ctime>
#include <sstream>
#include <bitset>
#include <deque>
#include <limits>
#include <numeric>
#include <functional>
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define sort(a,n,int) sort(a,a+n,less<int>())
using namespace std;
typedef long long ll;
typedef char ch;
typedef double db;
using namespace std;
ll a[1000000];
ll cnt = 0;
inline void mmp()
{
    for ( ll i = 1; i * i <= 2000000000; i++ )
    {
        a[cnt++] = i * i;
    }
}
ll x;
int main()
{
    mmp();
    while ( ~scanf ( "%lld", &x ) )
    {
        for ( ll i = 0; i < cnt; i++ )
        {
            if ( x < a[i] )
            {
                printf ( "%lld\n", a[i - 1] );
                break;
            }
        }
    }
    return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    int n;
    scanf("%d", &n);

    list<int> l;
    char com[20];

    rep(i, 0, n) {
        scanf("%s", com);
        if (com[6] == 'F') { l.pop_front(); }
        else if (com[6] == 'L') { l.pop_back(); }
        else if (com[0] == 'i') { int x; scanf("%d", &x); l.push_front(x); }
        else if (com[0] == 'd') {
            int x; scanf("%d", &x);
            for (auto itr = l.begin(); itr != l.end(); ++itr) {
                if (*itr == x) { l.erase(itr); break; }
            }
        }
    }

    int i = 0;
    for (auto itr = l.begin(); itr != l.end(); ++itr) {
        if (i++) { printf(" "); }
        printf("%d", *itr);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 34468
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

#include <iostream>
#include <algorithm>
using namespace std;
using int64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(x) cout << (x) << '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int64  a[100005][3];
    rep(i, n) {
        rep(j, 3) cin >> a[i][j];
    }

    int64 dp[100005][3] = {};

    rep(i, n){
        rep(j, 3){
            rep(k, 3) {
                if (j == k) continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    int64 ans = 0;

    rep(i, 3) ans = max(ans, dp[n][i]);

    print(ans);
    return 0;
}

Measured memory_bytes: 4992
let n = 
	let str = read_line () in
	Scanf.sscanf str "%d" (fun n -> n)

let digits =
	read_line ()
	|> Str.split (Str.regexp " ") 
	|> List.map int_of_string

let payment =
	let rec hasBadDigit n =
		if n <= 9 then
			List.exists (fun x -> x = n) digits
		else if List.exists (fun x -> x = n mod 10) digits then
			true
		else 
			hasBadDigit (n / 10)
	in
	let rec loop n =
		if hasBadDigit n then loop (n + 1)
		else n
	in
	loop n

let () =
	Printf.printf "%d\n" payment


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
#define N 1000000
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  preprocess();
  int k, x; cin>>k>>x;
  rep(i,max(-N, x-k+1), min(N+1, x+k)) {
    cout<<i<<" ";
  }
  cout<<endl;
}



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

int main() {
	int N;
  	cin >> N;
 	int a = N % 1000;
  	int b = N / 10;
  

  	if (a == 0 || a == 111 || a == 222 || a == 333 || a == 444 || a == 555 ||
        a == 666 || a == 777 || a == 888 || a == 999)
      cout << "Yes" << endl;
  
	else if (b == 111 || b == 222 || b == 333 || b == 444 || b == 555 ||
        b == 666 || b == 777 || b == 888 || b == 999)
      cout << "Yes" << endl;
  
  	else
      cout << "No" << endl;
}

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

int main(){
    uint_fast32_t N, W;
    scanf("%u%u", &N, &W);

    vector<int_fast64_t> ans(N * 1000 + 1, numeric_limits<int_fast64_t>::max() / 5);
    ans[0] = 0;

    {
        int_fast64_t w, v;
        for(auto i = 0; i < N; ++i){
            scanf("%lld%lld", &w, &v);

            for(auto j = N * 1000; j >= v; --j){
                ans[j] = min(ans[j], ans[j - v] + w);
            }
            for(auto j = v - 1; j >= 0; --j){
                ans[j] = min(ans[j], w);
            }
        }
    }

    printf("%ld\n", upper_bound(ans.begin(), ans.end(), W) - ans.begin() - 1);
    
    return 0;
}

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

using namespace std;

const int INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 ///   freopen("input.txt", "r", stdin);

    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    for(int & x : a)
        cin >> x;

    vector <int> dp(n, INF);
    dp[0] = 0;
    for(int i = 1; i < n; ++i)
    {
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        for(int j = 2; j <= min(k, i); ++j)
            dp[i] = min(dp[i], abs(a[i] - a[i - j]) + dp[i - j]);
    }
    cout << dp[n - 1] << '\n';

    return 0;
}



Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

class UnionFind():
	def __init__(self, n):
	 self.par = [i for i in range(n)]

	def root(self, x):
		if self.par[x] == x: return x
		self.par[x] = self.root(self.par[x])
		return self.par[x]
	
	def same(self, x, y):
		return 1 if self.root(x) == self.root(y) else 0
	
	def union(self, x, y):
		x, y = self.root(x), self.root(y)
		if x==y: return

		self.par[x] = y

n, q = MAP()
uf = UnionFind(n)
for _ in range(q):
	com, x, y = MAP()
	if com==0: uf.union(x, y)
	if com==1: print(uf.same(x, y))


Measured memory_bytes: 13100
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int a, b, k; cin >> a >> b >> k;
  int count = 0, i = 101;
  while(true) {
    i--;
    if (a % i == 0 && b % i == 0) { 
      count++;
    }
    if (count == k) break;
  }
  cout << i << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = 0;

    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            n += 1;
        }
    }

    cout << n << endl;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
ca_list = []
for i in range(n):
    ca_list.append(list(map(int, input().split())))
ans = 10**10
    
for i in range(2**n):
    suml = [0]*m
    money = 0
    for j in range(n):
        if i>>j&1:
            for k in range(1, m+1):
                suml[k-1] += ca_list[j][k]
            money += ca_list[j][0]
    ok = 1
    for a in range(m):
        if suml[a] < x:
            ok =0
            break
    if ok:
        ans = min(ans, money)

if ans == 10**10:
    print(-1)
else:
    print(ans)


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 2e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

ll ppow(ll x, ll y, ll mod)
{
  ll res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%mod;
    y = y >> 1;
    x = (x * x)%mod;
  }
  return res;
}

// Factorial with dp
ll factdp[N];
ll fact(ll x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2, M)) %= M;
  (res *= ppow(fact(n-r), M-2, M)) %= M;
  return res;
}

int main()
{
	ll n, m, k;
	cin>>n>>m>>k;
	ll ansn = 0;
	ll ansb = 0;
	ll ans = 1;
	rep(i, 1, n)
	{
		ansn = (ansn + (n - i)*i) % M;
	}
	ansn = (ansn * (m * m) % M) % M;
	rep(i, 1, m)
	{
		ansb = (ansb + (m - i)*i) % M;
	}
	ansb = (ansb * (n * n) % M) % M;
	ans = (ansb + ansn) % M;
	ans = (ans * modcomb(n*m-2, k-2)) % M;
	cout<<ans<<endl;
} 


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int MOD = 1e9 + 7;

bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof) {
    return firstElof.first > secondElof.first;
}

int main(void) {
    int N;
    cin >> N;

    vector<int> W(N);
    vector<int> S(N);
    for(int i=0;i<N;i++) {
        cin >> W.at(i);
        if(i==0) S.at(i) = W.at(i);
        else S.at(i) = S.at(i-1) + W.at(i);
    }

    int diff;
    for(int i=0;i<N-1;i++) {
        if(i==0) diff = S.at(N-1) - 2*S.at(i);
        else diff = min(diff, abs(S.at(N-1) - 2*S.at(i)));
    }

    cout << diff;
    return (0);
}


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

int main(void){
	int i,n,m,sum;

	while(cin>>n && n){
		for(i=sum=0;i<n*(n-1)/2;i++){
			cin>>m;
			sum+=m;
		}
		cout<<sum/(n-1)<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
def main():
    n, a, b = [int(x) for x in input().split()]
    res = 0
    for _ in range(n):
        if can_attend(int(input()), a, b):
            res += 1
    print(res)


def can_attend(class_time, a, b):
    if a <= class_time < b:
        return False
    return True


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	cin>>n;
	vector<int> h(n);
	rep(i,n)cin>>h[i];
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[0]-h[1]);
	repi(i,2,n) dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	OUT("square1001");
}


Measured memory_bytes: 3096
n1, n2 = [int(i) for i in input().split()]
s1 = input()
l1 = list(s1)
s2 = ""

for i1 in range(n1):
    if i1 == (n2 -1):
        l1[i1] = l1[i1] .lower()
    s2 +=l1[i1]

print(s2)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
vector<data_type>nod;
void nod_all(data_type n)
{
    nod.resize(n+7);
    for(data_type i=1; i<=n; i++)
        {
            for(data_type j=i; j<=n; j+=i)
                nod[j]+=1;
        }
    for(data_type i=2; i<=n; i++)
        nod[i]=(nod[i]*i)+nod[i-1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    nod_all(10000001);
    data_type n;
    cin>>n;
    cout<<nod[n]<<endl;


    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
#define print(x) cout<<'>'<<#x<<':'<<x<<endl;
#define F first
#define S second
const int mod=1000000007;

void solve(){

    float n;
    cin>>n;
    cout<<ceil(n/2);


}

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

    solve();

    return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define inf 1<<30
using namespace std;
const int MAXN=4010;
ll n,x,a[MAXN],nm[MAXN][MAXN];
int main()
{
	ll ans=0;
	scanf("%lld%lld",&n,&x);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]),a[n+i]=a[i],ans+=a[i];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			nm[i][0]=a[i];
			nm[i][j]=min(nm[i][j-1],a[n+i-j]);
		}
	}
	for(int k=0;k<n;k++){
		ll sum=0;
		for(int i=1;i<=n;i++){
			sum+=nm[i][k];
		}
		ans=min(ans,sum+x*k);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 62976
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  ll h,exp=1,ans=0;
  cin>>h;
  while(h!=1){
    h/=2;
    ++exp;
  }
  ans=pow(2,exp)-1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
constexpr int INF = 1001001001001001001LL;

/*
<NAME> 木の直径
<TRIGGER>
<TAG> graph, 木
<*NOTE>
- `vector<vector<pii>> &T`は木を表すグラフ(隣接リスト)
- `term_a`, `term_b`に有効なアドレスを指定するとそこに直径の両端となる頂点番号を入れる
<*CODE> */
int diameter(vector<vector<pii>> &T, int *term_a = nullptr, int *term_b = nullptr) {
    int N = sz(T);
    auto dfs = [&T, &N](int st) -> pii {
        vi dist(N, INF);
        auto rec = [&](auto f, int v, int p, int d) -> void {
            dist[v] = d;
            for (pii e : T[v]) {
                if (p != e.first) {
                    f(f, e.first, v, d + e.second);
                }
            }
        };
        rec(rec, st, -1, 0);

        int v = 0;
        rep(i, 0, N) if (dist[v] < dist[i]) v = i;
        return { dist[v], v };
    };
    pii a = dfs(0);
    pii b = dfs(a.second);
    if (term_a) *term_a = a.second;
    if (term_b) *term_b = b.second;
    return b.first;
}

signed main() {
    int N;
    cin >> N;
    vector<vector<pii>> G(N);
    rep(i, 0, N - 1) {
        int vs, vt, wei;
        cin >> vs >> vt >> wei;
        G[vs].push_back({vt, wei});
        G[vt].push_back({vs, wei});
    }
    cout << diameter(G) << endl;
}



Measured memory_bytes: 14328
class UnionFind:
    def __init__(self, N):
        self.parents = [i for i in range(N)]
        self.sizes = [1 for _ in range(N)]
        
    # 木の根をまとめる, 頂点 v が属するグループ番号を得る (O(α(n)))
    def root(self, x):
        if self.parents[x] == x:
            return x # 根
        else:
            self.parents[x] = self.root(self.parents[x]) # 経路圧縮
            return self.parents[x]
            
    # xとyが同じ集合に属するか否か
    def is_same(self, x, y):
        return self.root(x) == self.root(y)
        
    # xとyの属する集合を併合, 頂点 u が属するグループと頂点 v が属するグループを併合し、同じグループにする (O(α(n)))
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.sizes[x] += self.sizes[y]
        self.parents[y] = x
        return True
    
    # 頂点 v が属するグループと同じグループに属する頂点数を得る (O(1))
    def size(self, x):
        return self.sizes[self.root(x)]
        
        
        
N, M = map(int, input().split())

tree = UnionFind(N)

AB = []
for _ in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])

AB = AB[::-1]

tree = UnionFind(N)
ans = [N*(N-1)//2]
for i in range(M):
    a, b = AB[i]
    a, b = tree.root(a-1), tree.root(b-1)
    if a != b:
        ans.append(ans[-1] - tree.size(a)*tree.size(b))
    else:
        ans.append(ans[-1])
    tree.unite(a, b)

ans = ans[:M][::-1]
for i in range(M):
    print(ans[i])

Measured memory_bytes: 29228
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
		string s = Console.ReadLine();
		char[] ss = new char[4];
        for(int i = 0; i < 4; i++)
		{
			ss[i]= s[i];
		}
		if (ss[0] == ss[1] || ss[1] == ss[2] || ss[2] == ss[3])
		{
			Console.WriteLine("Bad");
		}
		else { Console.WriteLine("Good"); }
	}
}





Measured memory_bytes: 11092
#include<cstdio>
long long pow(long long x,long long n){
	long long ans=1;
	while(n){
		if(n&1)ans*=x;
		x*=x;
		n>>=1;
	}
	return ans;
}
long long n,k;
int main(){
	scanf("%lld%lld",&n,&k);
	if(k&1){
		printf("%lld",pow(n/k,3));
	}
	else{
		printf("%lld",pow(n/k,3)+pow((n+k/2)/k,3));
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
 	char string[5];
 	cin>>string;
  	char one,two;
  	one=string[0];
  	two='\0';
  	for(int i=0;i<4;i++)
      if(string[i]!=one)
      {
        	two=string[i];
        	break;
      }
  int count1=0;int count2=0;
  for(int i=0;i<4;i++)
  { if(string[i]==one)
      count1++;
  	else if(string[i]==two)
      count2++;
  }
  if(count1==2&&count2==2)
    	cout<<"Yes";
  else
    	cout<<"No";
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 100000000;
typedef pair<ll, ll> P;
int main() {
	int n, m;
	cin >> n >> m;
	P p[25];
	for (int i = 0; i < m; i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0; i < 1000; i++) {
		int keta = 1;
		int nx = i / 10;
		vector<int> d(1, i % 10);
		while (nx) {
			keta++;
			d.push_back(nx % 10);
			nx /= 10;
		}
		if (keta != n) {
			continue;
		}
		bool ok = true;
		reverse(d.begin(), d.end());
		for (int i = 0; i < m; i++) {
			if (d[p[i].first - 1] != p[i].second) {
				ok = false;
			}
		}
		if (ok) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
		
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int A[100][100], b[100], c[100] = {0};
	int i,j,n,m;
	
	scanf("%d %d",&n,&m);
	for (i=0; i<n; i++) {
		for (j=0; j<m; j++) {
			scanf("%d",&A[i][j]);
		}
	}
	for (j=0; j<m; j++) {
		scanf("%d",&b[j]);
	}
	for (i=0; i<n; i++) {
		for (j=0; j<m; j++) {
			c[i] += A[i][j] * b[j] ;
		}
	}
	for (i=0; i<n; i++) {
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 640
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


void main() {
    iota(readln.chomp.split[0].to!long)
        .map!(_ => readln.chomp.split.drop(1).to!(long[]).sort().array)
        .reduce!((a, b) => setIntersection(a, b).array)
        .count
        .writeln;
}


Measured memory_bytes: 380
n = int(input())
a = str(input())
b = str(input())
c = str(input())
result = 0
for i in range(n):
    counter = 1
    if a[i] == b[i]:
        counter += 1
    if a[i] == c[i]:
        counter += 1
    elif b[i] == c[i]:
        counter += 1
    result += abs(3-counter)
print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int n; cin >> n;
  vector<int> p(n); REP(i, n) cin >> p[i];
  int ans = 0;
  REP(i, n - 2) {
    if (p[i] < p[i+1] && p[i+1] < p[i+2]) ans++;
    if (p[i+2] < p[i+1] && p[i+1] < p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  
  int A,B; cin >> A >> B;
  
  if(0 <= A && A <= 5){
    cout << 0 << endl;
  }
  else if(6 <= A && A <= 12){
    cout << B/2 << endl;
  }
  else{
    cout << B << endl;
  }
  
  return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        ll sum = 0;
        int i = 1;
        for(; sum < N; i++) sum += i;
        
        int margin = sum - N;

        repeat(j, 1, i) {
            if(j != margin) cout << j << endl;
        }
       
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

int int_compare(const int* a, const int* b)
{
    if (*a > *b) {
        return 1;
    } else if (*a < *b) {
        return -1;
    }
    return 0;
}

int is_same_array(int a[], int b[], int n)
{
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            return 0;
        }
    }
    return 1;
}

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    int* arr = calloc(n, sizeof(int));
    int* sorted = calloc(n, sizeof(int));
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        sorted[i] = arr[i];
    }

    qsort(sorted, n, sizeof(int), (int (*)(const void*, const void*))(*int_compare));

    if (is_same_array(arr, sorted, n)) {
        printf("YES");
        return 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) {
                break;
            }
            swap(&arr[i], &arr[j]);
            if (is_same_array(arr, sorted, n)) {
                printf("YES");
                return 0;
            }
            swap(&arr[i], &arr[j]);
        }
    }
    printf("NO");
    return 0;
}


Measured memory_bytes: 128
n, t = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
inf  = float('inf')
ans = inf
for i in range(n):
    if a[i][1] <= t:
        ans = min(ans, a[i][0])
if ans == inf:
    print("TLE")
else:
    print(ans)


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

using namespace std;
using ll = long long;

int main() {
    const double mypi=3.14159265358979323846;
    double a,b;
    cin>>a>>b;
    int h,m;
    cin>>h>>m;
    double argh=2*mypi*(double)(h*60+m)/(double)720.0;
    double argm=2*mypi*(double)m/(double)60.0;
    argh=2*mypi-argh;
    argm=2*mypi-argm;
    double hx=a*cos(argh);
    double hy=a*sin(argh);
    double mx=b*cos(argm);
    double my=b*sin(argm);
    double ans=sqrt((hx-mx)*(hx-mx)+(hy-my)*(hy-my));
    cout<<setprecision(10);
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int Q;
  cin >> Q;
  
  while ( Q-- ) {
    int n;
    int cnt = 0;
    cin >> n;
    map<int, bool> used;
    while ( 1 ) {      
      if ( used[n] ) {
	cnt = -1;
	break;
      }
      used[n] = true;
      if ( n < 10 ) break;
      cnt++;
      int m = -1;
      for ( int i = 10; ; i *= 10 ) {
	if ( i > n ) break;
	m = max(m, (n/i)*(n%i));
      }      
      n = m;      
    }

    cout << cnt << endl;
  }
  
  return 0;
}



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

int main(){
    string S;
    cin >> S;
    int cnt1=0, cnt2=0;
    for(int i=0; i<S.length();i += 2){
        if(S[i] != '0'){
            cnt1++;
        }        
    }
    for(int i=1; i<S.length();i += 2){
        if(S[i] != '1'){
            cnt1++;
        }        
    }
    for(int i=0; i<S.length();i += 2){
        if(S[i] != '1'){
            cnt2++;
        }        
    }
    for(int i=1; i<S.length();i += 2){
        if(S[i] != '0'){
            cnt2++;
        }        
    }

    cout << min(cnt1, cnt2) << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


/////////////////////////////////////////////////////////////////////////////////////////

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

    ll x;
    cin >> x;

    ll ans = 0;
    ll a = x / 500;
    ll b = x / 5;

    if (a * 1000 > b * 5){
        ans += a * 1000;
        x %= 500;
        ans += (x / 5) * 5;
    }
    else {
        ans += b * 5;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A[100007],B[10007],C,D,E,F,K,G,H,L,M,N,P,Q,R,W,X,Y,Z;
string S[100];
ll dp[1007][10007];
ll pl,mi,cme;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    // 前処理
    COMinit();
  cin >> N >> K;
  rep(i,N){
    cin >> A[i];
  }
  sort(A,A+N);
  rep(i,N-K+1){
    mi+=(COM(N-i-1,K-1)%MOD)*A[i];
    mi%=MOD;
    pl+=(COM(i+K-1,K-1)%MOD)*A[i+K-1];
    pl%=MOD;
  }
  cout << (pl-mi+MOD*2)%MOD << endl;
}

Measured memory_bytes: 13312
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int A, B;
  cin >> A >> B;

  if(B%A == 0) cout << A+B << endl;
  else cout << B-A << endl;
  return 0;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var n int
var a []int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	if solve() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func solve() bool {
	c4 := 0
	c := 0

	for i := 0; i < n; i++ {
		if a[i]%4 == 0 {
			c4++
		} else if a[i]%2 == 1 {
			c++
		}
	}

	if c4+1 == c && n == (c4+c) {
		return true
	} else if c4 < c {
		return false
	}
	return true
}


Measured memory_bytes: 2944
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
hole = [0] * (N+1)
for i in range(M):
    hole[int(input())] = 1
if N == 1:
    print(1)
    exit()
if N == 2:
    if hole[1] == 1:
        print(1)
        exit()
    if hole[1] == 0:
        print(2)
        exit()
flg_one = False
flg_two = False
first = 1
second = 2
if hole[1] == 1:
    first = 0
    second = 1
    flg_one = True
if hole[2] == 1:
    first = 1
    second = 0
    flg_two = True
if flg_one and flg_two:
    print(0)
    exit()

for i in range(3,N):
    if hole[i] == 1:
        first = second
        second = 0
        continue
    tmp = first + second
    tmp %= 1000000007
    first = second
    second = tmp
tmp = first + second
tmp %= 1000000007
print(tmp)

Measured memory_bytes: 40940