akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
 
      	System.out.println(n*a>b ? b : n*a);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A),b(B),x(M),y(M),c(M);
  int i;
  int mina=100010,minb=100010;
  for(i=0;i<A;i++) {
    cin >> a[i];
    mina = min(mina,a[i]);
  }
  for(i=0;i<B;i++) {
    cin >> b[i];
    minb = min(minb,b[i]);
  }
  for(i=0;i<M;i++)cin >> x[i] >> y[i] >> c[i];
  int ans = mina + minb;
  for(i=0;i<M;i++) {
    ans = min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B;
	int ans = A * B;
	if (10 <= A or 10 <= B) ans = -1;
	cout << ans << endl;
}







Measured memory_bytes: 256
import sys
sys.setrecursionlimit(250000)

from scipy.special import comb
# a = comb(n, r)

def main():
    # a,b,c,d = map(int, input().split())
    n = int(input())

    # temp = (10 ** 9 + 7)
    # sum = 0
    # if n >= 2:
    #     for i in range(2, n+1):
    #         a = int(comb(i, 2)) * 2
    #         a = (a * 8**(i-2)) % temp
    #         sum = sum + a
    # else:
    #     print(0)

    print((10**n - 9**n*2 + 8**n) % (10 ** 9 + 7))

main()


Measured memory_bytes: 44116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0158
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int cnt = 0;
                while (n > 1)
                {
                    n = n % 2 == 0 ? n / 2 : 3 * n + 1;
                    cnt++;
                }
                Console.WriteLine(cnt);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 15940
#include<iostream>

int n,m,w[1000001],k;
bool cap(int mid){
  int res=1,now=0;
  for(int i=0;i<n;i++){
    now+=w[i];
    if(now>mid){
      res++;
      now=w[i];
    }
    if(w[i]>mid){
      return 0;
    }
  }
  return res<=k;
}

int main(){
  std::cin>>n>>k;
  for(int i=0;i<n;i++){
    std::cin>>w[i];
  }
  int p=0,r=1000000000;
  while(p<r){
    int mid=(p+r)/2;
    if(cap(mid)){
      r=mid;
    }else{
      p=mid+1;
    }
  }
  std::cout<<p<<"\n";
}



Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define LL long long
const LL MOD = 1e9 + 7;
const int SZ = 1e5 + 5;
using namespace std;

int main()
{
    int x[5];
    int a, b, c;
    cin >> a >> b >> c;
    x[0] = abs(a-b);
    x[1] = abs(a-c);
    x[2] = abs(b-c);
    sort(x, x+3);
    cout << x[0]+x[1] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n);
    int pc = 0, mc = 0, maxi = -M, mini = M, maxIdx = 0, minIdx = 0;
    for(int i = 0; i < n; i++){
        cin >> as[i];
        pc += as[i] > 0;
        mc += as[i] < 0;
        if(maxi < as[i]){
            maxi = as[i];
            maxIdx = i;
        }
        if(as[i] < mini){
            mini = as[i];
            minIdx = i;
        }
    }
    vector<pair<int, int>> ans;
    auto add = [&](int d, int f){ 
        ans.emplace_back(f, d);
        as[d] += as[f];
    };
    auto sub = [&](int d, int f){ 
        ans.emplace_back(f, d);
        as[d] -= as[f];
    };
    if(abs(maxi) >= abs(mini)){
        add(0, maxIdx);
        add(0, maxIdx);
        for(int i = 1; i < n; i++){
            add(i, i - 1);
            add(i, i - 1);
        }
    }
    if(abs(maxi) < abs(mini)){
        sub(n - 1, minIdx);
        sub(n - 1, minIdx);
        for(int i = n - 2; i >= 0; i--){
            sub(i, i + 1);
            sub(i, i + 1);
        }
    }
    cout << ans.size() << '\n';
    for(auto& a : ans){
        cout << a.first + 1 << ' ' << a.second + 1 << '\n';
    }
}


Measured memory_bytes: 888
from collections import deque
N,M = map(int,input().split())

root = [set()for i in range(N+1)]
ans = [0 for i in range(N+1)]

for i in range(M):
    a,b = map(int,input().split())
    root[a].add(b)
    root[b].add(a)

task = deque([1])
itta = {1}

while len(task) > 0:
    now = task.popleft()
    additionanl = root[now] - itta #到達済みを排除している
    for i in additionanl: #ノードチェック
        ans[i] = now 
        itta.add(i)
    task.extend(list(additionanl)) #チェックしたノードを追加
print("Yes")
for i in range(2,N+1):
    print(ans[i])



Measured memory_bytes: 68584
N, A, B = map(int, input().split())
S = input()

a = 0
b = 0

for i in range(N):
    flag = False
    if S[i] == 'a' and a < A + B:
        a += 1
        flag = True
    elif S[i] == 'b':
        if a < A + B and b < B:
            a += 1
            flag = True
        b += 1
    if flag:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

int dp[N];
int a[101],b[101];
int main(){
    //srand(time(NULL)+clock());
    int ca=0,T,k,i,j,m=0,K,n;
    double start=clock();
    scanf("%d%d",&n,&m);
    rep(i,0,n)scanf("%d%d",&a[i],&b[i]);
    int s=0;
    rep(i,1,N)dp[i]=inf;
    rep(i,0,n){
        per(j,0,s+1){
            if(a[i]+dp[j]<=m)Min(dp[j+b[i]],a[i]+dp[j]);
        }
        s+=b[i];
    }
    per(i,0,s+1)if(dp[i]<=m){
        printf("%d\n",i);break;
    }
    cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


Measured memory_bytes: 640
from collections import deque

X, N = map(int, input().split())
p = list(map(int, input().split()))
ans = X
queue = deque()
queue.append(X)
done_list = []
ans = []
while queue:
    var = queue.popleft()
    if var in p:
        done_list.append(var)
        if var - 1 not in done_list:
            queue.append(var-1)
        if var + 1 not in done_list:
            queue.append(var+1)
        continue
    else:
        ans = var
        break
print(ans)

Measured memory_bytes: 9464
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
///////////////////////////////////////


int p[200100];
double key[200100];
int main() {
	int N, K; cin >> N >> K;
	REP(i, N)cin >> p[i];
	REP(i, N) {
		key[i] = (1 + p[i])*p[i] / (2.0 * p[i]);
	}
	long double ans = 0;
	vector<long double>sum;
	sum.push_back(0);
	REP(i, N) {
		sum.push_back(sum[i] + key[i]);
	}
	REP(i, N - K + 1) {
		ans = max(ans, sum[i + K] - sum[i]);
	}
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 8432
#include <stdio.h>
#include <string.h>
int main() {
	char s[5], t[5], tmp;
	scanf("%s%s", s, t);
	int len = strlen(s);
	for (int i = 0; i < len / 2; i++) {
		tmp = s[i];
		s[i] = s[len - i - 1];
		s[len - i - 1] = tmp;
	}
	if (strcmp(s, t) == 0) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
int main()
{
	char z[200];
	while(~scanf("%s",z))
	 {
		int l=strlen(z);
		int count=0;
		for(int i=0;i<l/2;i++)
		{
			if(z[i]!=z[l-i-1])
			count++;
		}
		printf("%d\n",count);
		memset(z,'\0',sizeof(z));
	 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    if(N >= 10){
        N = N%10;
    }
    if(N == 3){
        cout << "bon";
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon";
    }else{
        cout << "hon";
    }

}

Measured memory_bytes: 3620
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)

int N, M;
long long p[1000010], b[1000010];

int main() {
    memset(p, 0, sizeof(p));
    
    cin >> N;
    for_(i,0,N) {
        long long a; cin >> a;
        p[a] += a;
    }
    
    for_(i,1,1000010) p[i] += p[i - 1];
    
    cin >> M;
    for_(i,0,M) cin >> b[i];
    
    for_(i,0,M) {
        ll c; cin >> c;
        if (c <= p[b[i]]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 14748
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    X, K, D = LI()
    X = abs(X)
    if X - K * D > 0:
        ans = X - K * D
    else:
        mi = X % D
        _mi = mi - D
        if abs(mi) > abs(_mi):
            mi = _mi # can be <0
        n_move = (X - mi) // D
        if n_move % 2 != K % 2:
            ans = min(abs(mi + D), abs(mi - D))
        else:
            a2 = abs(mi - D)
            ans = min(abs(mi), a2)
    print(ans)
main()



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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;


    cin >> d >> t >> s;

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

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll k,s=0; cin>>k;
	for(auto i=1;i<=k;++i){
		for(auto j=1;j<=k;++j){
			for(auto p=1;p<=k;++p){
				ll tmp=__gcd(i,j);
				tmp=__gcd(tmp,(ll)p);
				//cout<<tmp<<' ';
				s+=tmp;
			}
		}
	}
	//cout<<'\n';
	cout<<s<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 3644
(n, m) = list(map(int, input().split()))

py = []

for i in range(m):
    py.append(list(map(int, input().split())))

mapa ={}

for i in range(m):
    if py[i][0] in mapa:
        mapa[py[i][0]][py[i][1]] = i
    else:
        mapa[py[i][0]] = {py[i][1]:i}

ans = ['' for _ in range(m)]

for i in mapa:
    pri = mapa[i]
    pri = sorted(pri.items())
    for j in range(len(pri)):
        ans[pri[j][1]] = ('000000' + str(i))[-6:] + ('000000' + str(j + 1))[-6:]
for i in ans:
    print(i)

Measured memory_bytes: 74876
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	for (auto ch : s)
		if(ch=='7') {
			cout<<"Yes\n";
			return 0;
		}
	cout<<"No\n";
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;

int D; ll G; vi p,c; 
void input()
{
    cin >> D >> G;
    p.resize(D); c.resize(D);
    for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];
}

void solve()
{
    int ans = 1 << 20;
    for (int bit = 0; bit < (1 << D); ++bit){
        int num = 0;
        ll sum = 0;
        for (int i = 0; i < D; ++i){
            if (bit & (1 << i)){
                num += p[i];
                sum += 100 * (i+1) * p[i] + c[i];
            }
        }
        // cout << num << " " << sum << endl;
        if (sum >= G) ans = min (ans, num);
        else {
            for (int i = D-1; i >= 0; --i){
                if (bit & (1 << i)) continue;
                for (int j = 0; j < p[i]; ++j){
                    if (sum >= G) break;
                    num++;
                    sum += 100 * (i+1);
                }
            }
            // cout << num << " " << sum << endl;
            ans = min (ans, num);
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n;
  cin >> n;
  int cnt = 0;

  for (int i = 1; i <= n; i += 2) {
    int k = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) k++;
    }

    if (k == 8) cnt++;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
map<string,int> mp;
string ans[200001];
int now;
string s[200001];
int main()
{
	int n,maxn=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	sort(s,s+n);
	for(int i=0;i<n;i++)
	{
		mp[s[i]]++;
		if(mp[s[i]]>maxn)
		{
			now=0;
			ans[++now]=s[i];
			maxn=mp[s[i]];
		}
		else if(mp[s[i]]==maxn)
		{
			ans[++now]=s[i];
		}
	}
	for(int i=1;i<=now;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 28288
N = int(input())
A = list(map(int, input().split()))
sosu = 10 ** 9 + 7
dp = [0 for i in range(N)]
ans = 1
for i in range(N):
    if A[i] >= 1:
        nnn = dp[A[i]-1] - dp[A[i]]
    else:
        nnn = 3 - dp[A[i]]
    if nnn > 0:
        ans *= nnn
    elif nnn <= 0:
        ans *= 0
    ans = ans % sosu
    dp[A[i]] += 1
#print(dp)
print(ans)

Measured memory_bytes: 14396
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    while(true){
        scanf("%d %d",&a,&b);
        if(a == 0 && b == 0) break;
        if(a > b) printf("%d %d\n",b,a);
        else{
            printf("%d %d\n",a,b);
        }
    }
}


Measured memory_bytes: 2552
row = int(input())
array = list(map(int,input().split()))

ev = 0
count = 1

while count > 0:
  count = 0
  i = 0
  while i+1 in range(row):
    if array[i] > array[i+1]:
      ev = array[i] 
      array[i] = array[i+1]
      array[i+1] = ev
      count += 1
    else:
      i += 1

i = 0
Ans = array[i]
while i < row:
  if i == 0:
    Ans = array[i]
  else:
    Ans = (Ans + array[i]) / 2
  i += 1

print(Ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define ft first
#define sd second
#define flag bool fl=true

#define mod 1000003
#define N 100001
#define MX 1000000001
#define MXX 1000000000000000001

#define pb push_back
#define For(i, a, b) for(int i=a;i<=b;i++)
#define T int t, qq=0; cin>>t; while(qq++<t)
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define scarr(array, size) for(int i=0;i<size;i++) cin>>array[i]

#define deg(rad) (rad*180.0)/pi
#define pi acos(-1)
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)


/*
//----------useful_functions----------

long long extended_euclid(ll a, ll b, ll &x, ll &y){//ax+by=c
    if(b==0)
    {
        x=1, y=0;
        return a;
    }

    ll x1, y1;
    ll d=extended_euclid(b, a%b, x1, y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
long long bigMod(ll a, ll b){//(a^b)%mod
    ll ans=1;
    while(b)
    {
        if(b%2==1) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return ans%mod;
}
long long modInverse(ll a, ll b){//a*x=1 mod b
    ll x, y;
    ll gcd=extended_euclid(a, b, x, y);

    if(gcd==1) return ((x%b)+b)%b;
    else return 1;
}
long long nCr(ll n, ll r){//n<=1e6
    //declare globally-> ll fact[1000001];
    fact[1]=1;
    for(ll i=2;i<1000001;i++)
        fact[i]=(i*fact[i-1])%mod;

    return (fact[n]*modInverse(fact[r], mod)*modInverse(fact[n-r], mod))%mod;
}
long long josephus(ll n, ll k){//k'th person is killed out of n in the circle
    if(n==1) return 1;
    else return (josephus(n-1, k)+k-1)%n+1;
}
vector<int> sieve(ll n){//get primes up to n<=1e6 and the numbers can be handled up to 1e12
    bool fl[n+1];
    vector<int> primes;
    for(int i=0;i<=n;i++) fl[i]=false;

    for(int i=3;i*i<=n;i+=2)
        for(int j=i+i;j<=n;j+=i)
            fl[j]=true;

    primes.pb(2);
    for(int i=3;i<=n;i+=2) if(!fl[i]) primes.pb(i);
    return primes;
}

*/

int main()
{
    char a;
    cin>>a;
    if(a=='A') cout<<"T";
    else if(a=='T') cout<<"A";
    else if(a=='G') cout<<"C";
    else if(a=='C') cout<<"G";

//        cout<<"Case "<<qq<<": ";
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int k;
    cin>>k;
    string s;
    cin>>s;
    int ss = s.size();
    if(k>=ss){
        cout<<s<<endl;
    }else{
    for(int i = 0;i<min(k,ss);i++){
        cout<<s[i];
    }
    cout<<"...\n";

    }return 0;
}


Measured memory_bytes: 3612
X = int(input())

if X==1:
    print(1)
    exit()
    
ans = 0

for i in range(2, 50):
    if i*i<=X:
        p = i*i
        
        while p*i<=X:
            p *= i
        
        ans = max(ans, p)
    else:
        break

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int count = 0;
  if(S=="SRR") count = 2;
  if(S=="RSR") count = 1;
  if(S=="RRS") count = 2;
  if(S=="SSR") count = 1;
  if(S=="RSS") count = 1;
  if(S=="SRS") count = 1;
  if(S=="RRR") count = 3;
  cout << count << endl;
  return 0;
}

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

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

int main(){
string s,t;
cin>>s>>t;
sort(s.begin(),s.end());
sort(t.begin(),t.end(),greater<char>());
int count=0;
rep(i,s.size()){
if(s[i]<t[i]){
  cout<<"Yes"<<endl;
  return 0;
}
if(s[i]==t[i])
count++;
}
//cout<<"t=="<<t.size()<<"count=="<<count<<endl;
if(count==s.size()&&s.size()<t.size()){
cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;


  return 0;
}
// 1
//std::sort(v.begin(), v.end(), std::greater<Type>());

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++) cin >> S[i];
    vector<vector<char>> M(H+2,vector<char>(W+2));
    for(int i = 0; i < H+2; i++){
        for(int j = 0; j < W+2; j++){
            if(i == 0 || i == H+1) M[i][j] = 'o';
            else if(j == 0 || j == W+1) M[i][j] = 'o';
            else M[i][j] = S[i-1][j-1];
            /*cout << M[i][j]; 
            if(j == W+1) cout << endl;*/
        }
    }
    vector<vector<int>> T(H+2,vector<int>(W+2));
    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            if(M[i][j] == '#'){
                cout << '#';
            }
            else{
                for(int s = -1; s < 2; s++){
                    for(int t = -1; t < 2; t++){
                        if(M[i+s][j+t] == '#') T[i][j]++;
                    }
                }
                cout << T[i][j];
            }
            if(j == W) cout << endl;
        }
    }
 }

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

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

    ll gcd = GCD(a, b);

    cout << a * b / gcd << endl;
}

ll GCD (ll a, ll b) {
    if (a < b) {
       ll tmp = a;
       a = b;
       b = tmp;
   }

    ll r = 0;
    while (a % b != 0) {
        r = a % b;
        a = b;
        b = r;
    }

    return b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int answer;
	if (N <= 104) answer = 0;
	else if (N <= 134) answer = 1;
	else if (N <= 164) answer = 2;
	else if (N <= 188) answer = 3;
	else if (N <= 194) answer = 4;
	else answer = 5;
	cout << answer << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int minimum=1000;
  string s, t;
  cin >> s >> t;
  for(int i=0;i<s.size()-t.size()+1;i++){
    int c=0;
    for(int j=i;j<i+t.size();j++){
      if(s.at(j)!=t.at(j-i)) c++;
    }
    minimum=min(c, minimum);
  }
  cout << minimum << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
void dfs1(int &u, int nowcost, int &dis, int node, vector<bool> &used, vector<vector<pair<int, int> > > &adj){
    used[node] = true;
    if(dis < nowcost){
        dis = nowcost;
        u = node;
    }
    //cout << node << " " << nowcost << endl;
    for(int i = 0; i < (int)adj[node].size(); i++){
        //cout << "ok" << endl;
        int to = adj[node][i].first;
        int cost = adj[node][i].second;
        if(!used[to]){
            dfs1(u, nowcost + cost, dis, to, used, adj);
        }
    }    
}
 
void dfs2(int nowcost, int &dis, int node, vector<bool> &used, vector<vector<pair<int, int> > > &adj){
    used[node] = true;
    dis = max(dis, nowcost);
    //cout << node << " " << nowcost << endl;
    for(int i = 0; i < (int)adj[node].size(); i++){
        //cout << "ok" << endl;
        int to = adj[node][i].first;
        int cost = adj[node][i].second;
        if(!used[to]){
            dfs2(nowcost + cost, dis, to, used, adj);
        }
    }    
}
 
int main(){
    int n; cin >> n;
    if(n == 1) return !printf("First\n");
    vector<vector<pair<int, int> > > adj(n);
    for(int i = 0; i < n - 1; i++){
        int a, b, c; cin >> a >> b;
        a--;
        b--;
        adj[a].push_back({b, 1});
        adj[b].push_back({a, 1});
    }
 
    int u;
    int dis = 0;
    vector<bool> used(n, false);
    dfs1(u, 0, dis, 0, used, adj);
    for(int i = 0; i < n; i++) used[i] = false;
    dis = 0;
    dfs2(0, dis, u, used, adj);
    if(dis % 3 == 1) cout << "Second" << endl;
    else cout << "First" << endl;
    return 0;
}


Measured memory_bytes: 26880
#include <iostream>
#include <vector>

int N;
unsigned int temp, mask;
std::vector<unsigned int> result, origin;
std::vector<int> bitCount(32, 0);

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

    for(int i = 0;i < N;++i){
        scanf("%u", &temp);
        result.push_back(temp);
    }

    for(int bits = 0;bits < 32;++bits){
        mask = (unsigned int)1 << bits;
        for(int i = 0;i < result.size();++i){
            bitCount[bits] += !!(result[i] & mask);
        }
    }

    for(int i = 0;i < result.size();++i){
        temp = 0;
        for(int bits = 0;bits < 32;++bits){
            mask = (unsigned int)1 << bits;
            temp |= ((bitCount[bits] - !!(mask & result[i])) & 0x1) << bits;
        }
        origin.push_back(temp);
    }

    for(int i = 0;i < N;++i){
        printf("%d ", origin[i]);
    }
    
    return 0;
}

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

int main()
{
    string s;
    cin>>s;
    string frr;
    for(int i=0;i<s.size();i++)frr+='p';
    int counter=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='p'&&frr[i]=='p')counter++;
    }
    int k;

    if(s.size()%2==1)k=(s.size()/2)+1;
    else k=s.size()/2;
 //   k=k-counter;
   // cout<<k<<" "<<counter<<endl;
    for(int i=0;i<frr.size();i++)
    {
        if(frr[i]=='p'&&s[i]=='g')
        {
            frr[i]='g';
            k--;
            if(k<=0)break;
        }
    }
    //cout<<frr<<endl;
    int a=0,b=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='p'&&frr[i]=='g')a++;
        if(s[i]=='g'&&frr[i]=='p')b++;
    }
    cout<<max(0,b-a)<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll takahashi, aoki;
  if (c%b) takahashi = c/b+1;
  else takahashi = c/b;
  if (a%d) aoki = a/d+1;
  else aoki = a/d;
  if (takahashi <= aoki) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3588
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	L := make([]int, 2*N)
	for i := 0; i < 2*N; i++ {
		fmt.Scan(&L[i])
	}
	sort.Ints(L)
	ans := 0
	for i := 0; i < 2*N; i += 2 {
		ans += min(L[i], L[i+1])
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
#define int long long
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
typedef pair<int,int> P;
signed main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i+=2){
        int cnt = 0;
        for(int j=1; j<=n; j++){
            if(i % j == 0) cnt++;
        }
        if(cnt == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	ll a, b, c; cin >> a >> b >> c;
	if (a + b < c && 4 * a*b < (c - a - b)*(c - a - b)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int n, a;
    int tpcost;
    cin >> n >> a >> tpcost;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    
    int ans = 0;
    rep(i,n-1){
        int walkcost = (x[i+1]-x[i]) * a;
        ans += min(walkcost, tpcost);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1024
def main():

    n,a,b=map(int,input().split())

    if abs(a-b) % 2 == 0:
        print(abs(a-b)//2)
        return
    left=0
    temp = max(a,b)
    left = temp - 1
    right = 0
    temp = min(a,b)
    right = n - temp
    ans = min(left,right)

    tempR=b-a
    mid1=10**19
    if tempR-1>0:
        mid1=(tempR-1)//2 + a
    tempL=a+n-b+1
    mid2=10**19
    if n-tempL > 0:
        mid2=(n-tempL)//2 + n-b+1
    ans = min(ans,mid1,mid2)


    print(ans)
    return
if __name__=='__main__':
    main()


Measured memory_bytes: 38412
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int a,b;
  cin>>a>>b;
  llong ans = pow(100,a);
  if(b==100){
    ans *= 101;
  }else{
    ans *= b;
  }
  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <chrono>
#include <random>
#include <ctime>
#include <algorithm>
#include <iosfwd>
#include <iostream>
#include <list>
#include <ostream>
#include <streambuf>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fori(i, n) for(ll i = 0; i < (n); ++i)
#define forI(i, n) for(ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define ff first
#define ss second

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define pt pair<ll, ll>
#define x first
#define y second

pll operator+(pll a, pll b) { return {a.x + b.x, a.y + b.y}; }

ll rand0m() {
    return (ull(rand()) << 15ull | ull(rand()));
}                   //[0 ... n)
ll rand0m(ll x) {
    return rand0m() % x;
}               //[0 ... n)
ll rand0m(ll minn, ll maxx) {
    return rand0m(maxx - minn + 1) + minn;
}   //[minn ... maxx]

const ll MAXN = 2e5 + 1;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

ll n, m;

struct SegTree{
    vector<ll> t;
    
    explicit SegTree(ll siz){
        t.resize(siz * 4, 0);
    }
    
    void set(ull v, ull l0, ull r0, ull ind, ll val){
        if(l0 + 1 == r0){
            t[v] = val;
            return;
        }
        ull mid = (l0 + r0) >> 1ull;
        if(ind < mid){
            set(v << 1ull, l0, mid, ind, val);
            if(t[v] < t[v << 1ull]) t[v] = t[v << 1ull];
        }else {
            set(v << 1ull | 1ull, mid, r0, ind, val);
            if(t[v] < t[v << 1ull | 1ull]) t[v] = t[v << 1ull | 1ull];
        }
    }

    ll get(ull v, ull l0, ull r0, ull l, ull r){
        if(r <= l) return 0;
        if(l0 == l && r0 == r){
            return t[v];
        }
        ull mid = (l0 + r0) >> 1ull;
        return max(get(v << 1ull, l0, mid, l, min(mid, r)),
                get(v << 1ull | 1ull, mid, r0, max(l, mid), r));
    }
};

ll dp[10 * 1000 + 1][10][100];

void solve() {
    string s;
    ll d;
    cin >> s >> d;
    fori(i, 10) dp[0][i][i % d] = 1;
    forI(i, 10 * 1000){
        fori(j, 10){
            fori(k, d){
                dp[i][0][k] += dp[i - 1][j][k];
                if(dp[i][0][k] >= mod) dp[i][0][k] -= mod;
            }
        }

        forI(j, 9){
            dp[i][j][0] = dp[i][j - 1][d - 1];
            forI(k, d - 1) dp[i][j][k] = dp[i][j - 1][k - 1];
        }
    }
    ll c = 0;
    ll offset = 0;
    fori(i, s.size()){
        fori(j, s[i] - '0') {
            c += dp[s.size() - i - 1][j][offset];
            if(c >= mod) c -= mod;
        }
        offset = (offset - (s[i] - '0') + 100 * d) % d;
    }
    c += dp[0][s.back() - '0'][(offset + s.back() - '0') % d];
    cout << (c - 1 + mod) % mod;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  int a = 0;
  cin >> n;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
       if(j*i == n){
         cout << "Yes" << endl;
         a++;
         break;
       }
     }
   if(a == 1)break;
  }
  if(a == 0)cout << "No" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

char board[1005][1005];
int di[] = { -1, 0, 1, 0 };
int dj[] = { 0, 1, 0 , -1};

int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	REP(i, h)scanf("%s", board[i]);
	deque<PII> q[2];
	REP(i, h) {
		REP(j, w) {
			if (board[i][j] == '#')q[0].push_back(MP(i, j));
		}
	}
	int ans = 0;
	while (!q[ans % 2].empty()) {
		while (!q[ans % 2].empty()) {
			auto tmp = q[ans % 2].front();
			q[ans % 2].pop_front();
			REP(d, 4) {
				int ni = tmp.first + di[d];
				int nj = tmp.second+ dj[d];
				if (ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
				if (board[ni][nj] == '.') {
					q[(ans + 1) % 2].push_back(MP(ni, nj));
					board[ni][nj] = '#';
				}
			}
		}
		ans++;
	}
	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 9360
#include "bits/stdc++.h"

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r0, w, c, r;
	while (cin >> r0 >> w >> c >> r&&r0) {
		int i = 0;
		while (r0 + i*r < c*w)++i;
		cout << i << endl;
	}
	return 0;
}

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

int main(){
      int n,t;cin >> n >> t;
      int ans = INT_MAX;
      bool flag = false;
      for(int i = 0;i < n;i++){
            int c,ti;cin >> c >> ti;
            if(ti <= t && c < ans){
                  ans = c;
                  flag = true;
            }
      }
      if(flag)cout << ans;
      else cout << "TLE";
}

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

int main() {
  long double a,b,h,m;
  cin>>a>>b>>h>>m;
  long double kakudo=m*PI/30-(h*PI/6+m*PI/360);
  long double ans=a*a+b*b-2*a*b*cos(kakudo);
  cout<<std::fixed << std::setprecision(10)<<sqrt(ans)<<endl;
}


Measured memory_bytes: 4144
def solve():

    N, M = map(int, input().split())
    X = list(map(int, input().split()))

    if N >= M:
        print(0)
        exit()

    X.sort()
    L = []
    for i in range(M-1):
        # 各点の距離を格納
        L.append(X[i+1]-X[i])
    L.sort()
    # 遠い距離を除いた分の距離の合計
    print(sum(L[:M-N]))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 56744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const ll mod = 1e9 + 7;
const ll MAX_L = 1e5;
ll p[MAX_L+1];

ll pow3(ll n){
  if(n < 0) return 0;
  else return p[n];
}

int main(){
  p[0] = 1;
  rep(i, MAX_L) p[i+1] = p[i]*3 % mod;
  string s;
  cin >> s;
  ll na = 0, nq = 0, tq = 0;
  int l = s.length();
  rep(i, l) if(s[i] == '?') tq++;
  ll dp[l+1] = {0}, ab[l+1] = {0}, aq[l+1] = {0}, qb[l+1] = {0};
  rep(i, l){
    if(s[i] == 'A'){
      dp[i+1] = dp[i], ab[i+1] = ab[i], aq[i+1] = aq[i], qb[i+1] = qb[i];
      na++;
    } else if(s[i] == 'B'){
      dp[i+1] = dp[i], ab[i+1] = ab[i] + na, qb[i+1] = qb[i] + nq, aq[i+1] = aq[i];
    } else if(s[i] == 'C'){
      dp[i+1] = (dp[i] + aq[i]*pow3(tq-1) % mod + qb[i]*pow3(tq-1) % mod + pow3(tq-2)*nq*(nq-1)/2 % mod + ab[i]*pow3(tq) % mod) % mod;
      ab[i+1] = ab[i], aq[i+1] = aq[i], qb[i+1] = qb[i];
    } else if(s[i] == '?'){
      dp[i+1] = (dp[i] + ab[i]*pow3(tq-1) % mod + qb[i]*pow3(tq-2) % mod + aq[i]*pow3(tq-2) % mod + pow3(tq-3)*nq*(nq-1)/2 % mod) % mod;
      aq[i+1] = aq[i] + na, ab[i+1] = ab[i], qb[i+1] = qb[i];
      nq++;
    }
  }
  cout << dp[l] << endl;
  return 0;
}


Measured memory_bytes: 4352
import sys
X = int(input())
MOD = 10**9+7
M = [i*m for i in range(0, 10**4) for m in [-1, 1]]
for i in range(0, 10**4):
  for j in M:
    if i == j:
      break
    if X%(i-j)==0:
      if i**5-j**5==X:
        print(i, j)
        sys.exit(0)


Measured memory_bytes: 68276
#include <stdio.h>
int max(long long x, long long y) { return x > y ? x : y; }
int main() {
	long long a, b, c, x, y, min = 1e18, ans;
	scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
	for (long long i = 0; i <= 1e5; i++) {
		ans = i * 2 * c;
		ans += max(x - i, 0) * a;
		ans += max(y - i, 0) * b;
		if (ans < min) min = ans;
	}
	printf("%lld\n", min);
	return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();
        int K = in.nextInt();
        int displayR ;
        if(N < 10 ){
            displayR =  K + (100 * (10 - N));

        }else displayR = K;

        out.println(displayR);



        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h> 
using namespace std;
int a[5],ans,now;

int check(int x)
{
	if (x % 10 == 0) return x;
		else return x - x % 10 + 10;
}

int cnt(int i1, int i2, int i3, int i4, int i5)
{
	int sum = a[i1];
	sum = check(sum);
	sum += a[i2];
	sum = check(sum);
	sum += a[i3];
	sum = check(sum);
	sum += a[i4];
	sum = check(sum);
	sum += a[i5];
	return sum;
}
int main()
{
	ans = 2e9;
	for(int i = 0; i < 5; i++)
		cin >> a[i];
	for(int i1 = 0; i1 < 5; i1++){
		for(int i2 = 0; i2 < 5; i2++)
			if(i1!=i2){
				for(int i3 = 0; i3 < 5; i3++)
					if(i3 != i2 && i3 != i1){
						for(int i4 = 0; i4 < 5; i4++)
							if(i4 != i1 && i4 != i3 && i4 != i2 && i4 != i1){
								for(int i5 = 0; i5 < 5; i5++)
									if(i5 != i4 && i5 != i3 && i5 != i2 && i5 != i1){
										ans = min(ans, cnt(i1,i2,i3,i4,i5));
									}
							}
					}
			}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  
  int N,K,X,sum=0;
  cin >> N >> K;
  

  for(int i=0; i<N; i++){
    
    cin >> X;
    
    
    if(2*X<K)
      sum += 2*X;
    else
      sum += 2*(K-X);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second


const int maxn = 1e5 + 10;
int n, m;
vector<int> g[maxn];
int c[maxn];
int cnt[3];
void dfs(int x, int t) {
  c[x] = t;
  cnt[t]++;
  for (int y : g[x]) {
    if (!c[y]) {
      dfs(y, 3 - t);
    } else if (c[y] != 3 - t) {
      printf("%lld\n", 1LL * n * (n - 1) / 2 - m);
      exit(0);
    }
  }
}

int main() {
  scanf("%d%d", &n, &m);
  REP(i, m) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].PB(v);
    g[v].PB(u);
  }
  dfs(1, 1);
  printf("%lld\n", 1LL * cnt[1] * cnt[2] - m);
  return 0;
}



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

const int INF = 100000;
int d[100][100];
void init()
{
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			if(i == j){
				d[i][j] = 0;
			}else{
				d[i][j] = INF;
			}
		}
	}
}

int main()
{
	int n;
	cin >> n;
	init();
	for(int i=0;i<n;i++){
		int a,m;
		cin >> a >> m;
		for(int j=0;j<m;j++){
			int b;
			cin >> b;
			d[a-1][b-1] = 1;
		}
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				int dis = d[i][k]+d[k][j];
				if(dis < d[i][j]){
					d[i][j] = dis;
				}	
			}
		}
	}
	int p;
	cin >> p;
	for(int j=0;j<p;j++){
		int a,b,pket;
		cin >> a >> b >> pket;
		if(d[a-1][b-1]+1 <= pket && d[a-1][b-1] != INF)
			cout << d[a-1][b-1]+1  << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main() {
  int a, b, c, x;
  std::cin >> a >> b >> c >> x;

  int ans { 0 };
  for(int i = 0; i <= a; ++i) {
    for(int j = 0; j <= b; ++j) {
      for(int k = 0; k <= c; ++k) {
        const int total { 500 * i + 100 * j + 50 * k };
        ans += (total == x ? 1 : 0);
      }
    }
  }

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


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



int main(){
   int a, b, x;
   cin >> a >> b >>x;
   if(a==x) cout << "YES" <<endl;
   else if(x-a>=0&&b>=(x-a)) cout << "YES" << endl;
   else cout << "NO" << endl;
      }

Measured memory_bytes: 256