akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define LOOP_INIT 0																						/* ??????????????????						*/
#define SORT_CNT_INIT 0																					/* ??????????????°?????????????????????			*/
#define TRUE 1																							/* ??£??????							*/
#define FALSE 0																							/* ?????????							*/
#define TESTCASE_ARRAY_MAX 100																			/* ????´???????????????§???					*/
#define EXIT_SUCCESS 0																					/* ??£?????????????????????					*/
#define PREV_ITEM( x ) x - 1																			/* 1?????????????´?						*/

int main( void )
{
	unsigned char aubW_Dtestcase[ TESTCASE_ARRAY_MAX ];													/* ????´???????							*/
	unsigned char ubW_Dtc_cnt;																			/* ????´???°							*/
	unsigned char ubW_Dchange;																			/* ????????¨?????°						*/
	unsigned char ubW_Ctc_loop_cnt;																		/* ?????????????????????					*/
	unsigned short usW_Csort_cnt = SORT_CNT_INIT;														/* ??????????????°????????????				*/
	unsigned char ubW_Floop_flug = TRUE;																/* ?????????????????°						*/

	scanf("%d", &ubW_Dtc_cnt );																			/* ????´???°?????\???						*/
	/* ??\?????¨????????? */
	for( ubW_Ctc_loop_cnt = LOOP_INIT; ubW_Ctc_loop_cnt < ubW_Dtc_cnt; ubW_Ctc_loop_cnt++ ){
		scanf("%d", &aubW_Dtestcase[ ubW_Ctc_loop_cnt ] );												/* ????´??????\???						*/
	}

	/* ?????????????????°???TRUE??????????????? */
	while( ubW_Floop_flug ){
		ubW_Floop_flug = FALSE;																			/* ?????????????????°???FALSE???			*/
		/* ???????????¨????????? */
		for( ubW_Ctc_loop_cnt = LOOP_INIT; ubW_Ctc_loop_cnt < ubW_Dtc_cnt; ubW_Ctc_loop_cnt++ ){
			/* 1?????????????´?????????¨???????´?????????§????????´??? */
			if( aubW_Dtestcase[ ubW_Ctc_loop_cnt ] < aubW_Dtestcase[ PREV_ITEM( ubW_Ctc_loop_cnt ) ] ){
				ubW_Dchange = aubW_Dtestcase[ ubW_Ctc_loop_cnt ];										/* ????????¨?????°???????´??????????			*/
				aubW_Dtestcase[ ubW_Ctc_loop_cnt ] = aubW_Dtestcase[ PREV_ITEM( ubW_Ctc_loop_cnt ) ];	/* ?????¨???????´????1?????????????´?????????????	*/
				aubW_Dtestcase[ PREV_ITEM( ubW_Ctc_loop_cnt ) ] = ubW_Dchange;							/* 1?????????????´?????????¨???????´?????????????	*/
				ubW_Floop_flug = TRUE;																	/* ?????????????????°???TRUE???				*/
				usW_Csort_cnt++;																		/* ??????????????°???????????????+1			*/
			}
			else{
				/* else?????????????????????????????\ */
			}
		}/* ???????????¨?????????????????? */
	}/* ?????????????????°???TRUE???????????????????????? */

	/* ????????¨????????? */
	for( ubW_Ctc_loop_cnt = LOOP_INIT; ubW_Ctc_loop_cnt < PREV_ITEM( ubW_Dtc_cnt ); ubW_Ctc_loop_cnt++ ){
		printf("%d ", aubW_Dtestcase[ ubW_Ctc_loop_cnt ] );												/* ????´???°-1?????§???????´??????????			*/
	}
	printf("%d\n", aubW_Dtestcase[ PREV_ITEM( ubW_Dtc_cnt ) ]);											/* ?????????????´???????????????????			*/
	printf("%d\n", usW_Csort_cnt);																		/* ??????????????°?????????					*/
	return EXIT_SUCCESS;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main()
{
	int N,K,score;
	scanf("%d%d",&N,&K);
	double res=0,cnt;
	for(int i=1;i<=N;i++){
		score=i;
		cnt=1;
		while(score<K)
		{
			score*=2;
			cnt/=2;
		}
		res+=cnt;
	}
	printf("%.12lf",res/N);
	return 0;
 } 

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int a,b; cin >> a >> b;
    for(int i = 1; i < 1300; i++){
        if(floor(i*0.08) == a && floor(i*0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val x1 = sc.nextInt
    val y1 = sc.nextInt
    val x2 = sc.nextInt
    val y2 = sc.nextInt

    val dx = x2 - x1
    val dy = y2 - y1

    val x3 = x2 - dy
    val y3 = y2 + dx

    val x4 = x3 - dx
    val y4 = y3 - dy

    "%d %d %d %d".format(x3, y3, x4, y4)
  }
}


Measured memory_bytes: 25892
#include <iostream>
#include <map>
using namespace std;
int main(){
  
  pair <int,int> tile[100][100];
  int n,hata[100][100],i,j,x,y,result,a;
  
  while(cin>>n,n){
  
  for(i=0;i<n;i++) for(j=0;j<n;j++){
      cin>>x>>y;
      tile[i][j]=make_pair(x,y);
    }
   for(i=0;i<n;i++) for(j=0;j<n;j++) hata[i][j]=20000;
  
  result=0;
  a=0;
  for(i=0;i<n;i++) for(j=0;j<n;j++){
      if(hata[i][j]==20000){
        a++;
        //cout<<a<<endl;
        y=i;
        x=j;
        result++;
        while(1){
          if(hata[y][x]<a){
            result--;
            break;
          } else if(hata[y][x]==a) break;
          hata[y][x]=a;
          int y1=y,x1=x;
          y=tile[y1][x1].second;
          x=tile[y1][x1].first;
        
        }
      }
    }
  cout<<result<<endl;
  }
  
  return 0;
  
}

  

Measured memory_bytes: 3220
// https://atcoder.jp/contests/abc082/tasks/abc082_b
"use strict"
function Main(input) {
  const params = input.split('\n');
  const s = params[0];
  const sLen = s.length;
  const t = params[1];
  const tLen = t.length;
  
  const sort_s = s.split('').sort((a, b) => a < b ? -1 : 1);
  const sort_t = t.split('').sort((a, b) => a < b ? 1 : -1);
  
  let eqflag = true;
  for (let i = 0; i < sLen; i++) {
    if (sort_s[i] < sort_t[i]) {
      console.log('Yes');
      return;
    }

    if (sort_s[i] !== sort_t[i]) {
      eqflag = false;
    }
  }

  if(sLen < tLen && eqflag) {
    console.log('Yes');
    return;
  }
  console.log('No');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7752
// problem: "https://atcoder.jp/contests/abc158/tasks/abc158_d"

#include<bits/stdc++.h>

using namespace std;

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

    int q;
    cin>>q;

    deque<char>B,E;
    int c = 0;

    while(q--)
    {
        int t;
        cin>>t;

        if(t == 1)
            c++;

        else
        {
            int f;
            char ch;

            cin>>f>>ch;

            if(c%2)
            {
                if(f == 1)
                    E.push_back(ch);
                else
                    B.push_back(ch);
            }
            else
            {
                if(f == 1)
                    B.push_back(ch);
                else
                    E.push_back(ch);
            }
        }
    }

    if(c%2)
    {
        while(!E.empty())
        {
            cout<<E.back();
            E.pop_back();
        }

        reverse(s.begin(),s.end());
        cout<<s;

        while(!B.empty())
        {
            cout<<B.front();
            B.pop_front();
        }
    }
    else
    {
        while(!B.empty())
        {
            cout<<B.back();
            B.pop_back();
        }

        cout<<s;

        while(!E.empty())
        {
            cout<<E.front();
            E.pop_front();
        }
    }

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
using namespace std;
int main(void){
	int a,b,c,d;
	int sum = 0;
	cin>>a>>b>>c>>d;
	if(a>=b){
		sum +=b;
	}else{
		sum +=a;
	}if(c>=d){
		sum +=d;
	}else{
		sum+=c;
	}
	cout << sum;
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if ((a*b)>(c*d)){
        cout<<a*b<<endl;
    }else cout<<c*d<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h> 
#include <set>

using namespace std;

#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9 + 7;

bool IsPrime(int num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}


int main() {
    int N, K;
    cin >> N >> K;
    vi A(N);
    vi B(N, 0);
    set<int> S;
    rep(i, N) {
        cin >> A[i];
        S.insert(A[i]);
    }
    for (int x : A) {
        B[x-1]++;
    }
    sort(B);
    int ans = 0;
    int n = S.size();
    if (n > K) {
        rep(i, N - K)ans = ans + B[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<vector>
signed
main(){
    int n;
    std::cin >> n;
    std::vector<int>v(n);
    for(auto&& e : v)
        std::cin >> e;
    for(int i = 1; i < n; ++i){
        if(v[i] - v[i-1] > 0) --v[i];
        if(v[i] - v[i-1] < 0) return puts("No") *0;
    }
    std::cout << "Yes" << std:: endl;
}


Measured memory_bytes: 640
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] dp = new int[n + 1];
        dp[0] = 0;
        for (int i = 1; i <= n; i++)
        {
            dp[i] = i;

            int power = 6;
            while (power <= i)
            {
                dp[i] = Math.Min(dp[i], dp[i - power] + 1);
                power *= 6;
            }

            power = 9;
            while (power <= i)
            {
                dp[i] = Math.Min(dp[i], dp[i - power] + 1);
                power *= 9;
            }
        }

        Console.WriteLine(dp[n]);
    }
}

Measured memory_bytes: 13140
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
int x[101], y[101];

int main(){
    cin >> n;
    REP(i, n){
        cin >> x[i] >> y[i];
    }
    double ans = 0.0;
    REP(i, n){
        if(x[i] == 0 && y[i] == 0)continue;
        double a = -atan2(x[i], y[i]) + 1e-9;
        double tmpx1 = 0.0, tmpy1 = 0.0, tmpx2 = 0.0, tmpy2 = 0.0;
        REP(j, n){
            double dx = cos(a) * y[j] - sin(a) * x[j];
            double dy = sin(a) * y[j] + cos(a) * x[j];
            if(dy > 0.0){
                tmpx1 += dx;
                tmpy1 += dy;
            }else{
                tmpx2 += dx;
                tmpy2 += dy;
            }
        }
        ans = max(ans, hypot(tmpx1, tmpy1));
        ans = max(ans, hypot(tmpx2, tmpy2));
    }
    cout << ans << endl;
}

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

pair<map<ll, ll>, set<ll>> prime_factor(ll n){
    map<ll, ll> res;
    set<ll> primes;
    for(ll i = 2; i*i <= n; ++i) {
        if(n%i==0) primes.insert(i);

        while(n%i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) {
        res[n] = 1;
        primes.insert(n);
    }
    return make_pair(res, primes);
}

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

    ll n;
    cin >> n;

    pair<map<ll, ll>, set<ll>> mpst = prime_factor(n);

    map<ll, ll> mp = mpst.first;
    set<ll> st = mpst.second;

    // cout << st.size() << endl;
    int res = 0;
    for(auto ele: st){
        // cout << ele << " " << mp[ele] << endl;
        int sm = 0;
        int nm = mp[ele];
        int cnt = 1;
        while(1){
            if(nm >= cnt){
                nm -= cnt;
                ++sm;
                ++cnt;
            }
            else break;
        }

        res += sm;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    long long a = 2;
    long long b = 1;
    if(N == 0) {
        cout << a << endl;
        return 0;
    }
    if(N == 1) {
        cout << b << endl;
        return 0;
    }
    REP(i, N) {
        long long tmpa = b;
        b = a + b;
        if(i == N - 2) {
            cout << b << endl;
            return 0;
        }
        a = tmpa;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

int main() {
  double N;
  cin >> N;
  int a = N/2;
  //cout << a << endl;
  cout <<  fixed << setprecision(7) << (N-a)/N << endl;
  return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, r; cin >> n >> r;
    if (n >= 10) cout << r << "\n";
    else {
        cout << r + 100 * (10 - n) << "\n";
    }
    return 0;
}

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

ll kai(ll x) {
  ll a = 1;
  for (int i = 1; i <= x; i++) {
    a *= i;
    a %= 1000000007;
  }
  
  return a;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  ll X,Y;
  cin >> X >> Y;
  if (X < Y) swap(X,Y);
  ll ans = 0;
  
  if ((X + Y) % 3 == 0 && X <= 2 * Y) {
    ll k = (X + Y) / 3;
    ll XY = kai(X -k + Y -k);
    ll XX = kai(X - k);
    ll YY = kai(Y - k);
    ll XXX = modinv(XX,1000000007);
    ll YYY = modinv(YY,1000000007);
    ans = XY * XXX;
    ans %= 1000000007;
    ans *= YYY;
    ans %= 1000000007;
  }
  
  cout << ans << endl;        
}

Measured memory_bytes: 256
s = input()
t = input()

S = list(s)
T = list(t)

count = 0
for i in range(len(S)):
    S.insert(0,S[len(S)-i-1])
    ans = S[0:len(S)-i-1]
    if ans == T:
        print("Yes")
        count = 1
        break
if count == 0:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(((double)(a+b)/2 - (a+b)/2) >= 0.5){
    cout << (a+b)/2+1 << endl;
  }else{
    cout << (a+b)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import deque

def main():
  n, q = map(int, input().strip().split())
  tree = [[] for _ in range(n)]
  for _ in range(n-1):
    a, b = map(int, input().strip().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)
    
  
  counter = [0] * n
  for _ in range(q):
    p, x = map(int, input().strip().split())
    p -= 1
    counter[p] += x

  def bfs(root):
    visited = [False] * n
    dq = deque()
    dq.append(0)
    visited[0] = True
    while dq:
      inode = dq.popleft()
      for ichild in tree[inode]:
        if visited[ichild]:
          continue
        counter[ichild] += counter[inode]
        visited[ichild] = True
        dq.append(ichild)
    
  bfs(tree[1])
  print(' '.join(map(str, counter)))

if __name__=='__main__':
  main()



Measured memory_bytes: 130964
ic=lambda i,c:i+c*50
n,m,s=map(int,input().split())
edge=[[]for _ in range(125100)]
for _ in range(m):
  u,v,a,b=map(int,input().split())
  u-=1
  v-=1
  for i in range(a,2501):
    edge[ic(u,i)].append((ic(v,i-a),b))
    edge[ic(v,i)].append((ic(u,i-a),b))
for i in range(n):
  c,d=map(int,input().split())
  for j in range(c,2501):
    edge[ic(i,j-c)].append((ic(i,j),d))
from heapq import heappop,heappush
def dijkstra(s,n,edge):
  inf=10**20
  ans=[inf]*n
  ans[s]=0
  h=[[0,s]]
  while h:
    c,v=heappop(h)
    if ans[v]<c:continue
    for u,t in edge[v]:
      if c+t<ans[u]:
        ans[u]=c+t
        heappush(h,[c+t,u])
  return ans
d=dijkstra(ic(0,min(2500,s)),125100,edge)
ans=[0]+[10**20]*(n-1)
for i in range(1,n):
  for j in range(2501):ans[i]=min(ans[i],d[ic(i,j)])
print(*ans[1:])


Measured memory_bytes: 126648
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if X == 500*i+100*j+50*k:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define MAXN 1000
struct node{
    int x,y,st;
    bool operator == (node B) const{
        return x==B.x&&y==B.y;
    }
};
int H,W,N;
char Map[MAXN+5][MAXN+5];
bool vis[MAXN+5][MAXN+5];

const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int bfs(node S,node T){
    queue<node> Q;
    Q.push(S);
    memset(vis,0,sizeof vis);
    while(!Q.empty()){
        node u=Q.front();Q.pop();
        for(int i=0;i<4;i++){
            node tmp=u;
            tmp.x+=dir[i][0],tmp.y+=dir[i][1],tmp.st++;
            if(tmp.x<1||tmp.x>H||tmp.y<1||tmp.y>W||vis[tmp.x][tmp.y]||Map[tmp.x][tmp.y]=='X')
                continue;
            if(tmp==T)
                return tmp.st;
            vis[tmp.x][tmp.y]=1;
            Q.push(tmp);
        }
    }
    return -1;
}

pair<int,int> pos[10];

int main(){
    scanf("%d%d%d",&H,&W,&N);
    for(int i=1;i<=H;i++)
        scanf("%s",Map[i]+1);
    node S;
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++){
            if(Map[i][j]!='.'&&Map[i][j]!='X'&&Map[i][j]!='S')
                pos[Map[i][j]-'1'+1]=make_pair(i,j);
            if(Map[i][j]=='S')
                S.x=i,S.y=j,S.st=0;
        }
    int Ans=0;
    for(int i=1;i<=N;i++){
        Ans+=bfs(S,(node){pos[i].first,pos[i].second,0});
        S=(node){pos[i].first,pos[i].second,0};
    }
    printf("%d\n",Ans);
}



Measured memory_bytes: 4688
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int H = sc.nextInt();
			final int M = sc.nextInt();
			
			final double Ax = A * Math.cos(2 * Math.PI * ((60 * H + M) * 60) / (12 * 60 * 60));
			final double Ay = A * Math.sin(2 * Math.PI * ((60 * H + M) * 60) / (12 * 60 * 60));
			
			final double Bx = B * Math.cos(2 * Math.PI * M / 60);
			final double By = B * Math.sin(2 * Math.PI * M / 60);
			
			final double dist = Math.sqrt((Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By));
			
			System.out.printf("%.10f\n", dist);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 34640
/**
 * author  : UshanGhosh
 * created : 2020-08-31 19:45:20
**/ 

#include<bits/stdc++.h>
using namespace std;

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     1000000007
#define    inf     1e18
#define    endl    '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    while(t--){
        long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
        cin>>n;
        ll ar[n];
        for(i=0;i<n;i++) cin>>ar[i];
        ll sum[n];
        for(i=0;i<n;i++){
            if(i==0) sum[i]=ar[i];
            else sum[i]=sum[i-1]+ar[i];
        }
        ll ans = 0;
        for(i=0;i<n;i++){
            ans=(ans+ar[i]*((sum[n-1]-sum[i])%mod))%mod;
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 6748
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

def ceil(n, m):
    if n % m == 0:
        return int(n / m)
    else:
        return int(n / m) + 1

aa = ceil(n, a)
bb = ceil(n, b)
cc = ceil(n, c)
dd = ceil(n, d)
ee = ceil(n, e)

lag = max([aa, bb, cc, dd, ee]) - 1

print(5 + lag)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int card[4][13]={0};
    for(int i=0;i<n;i++){
        char s;
        int b;
        cin >> s >> b;
        
        if(s=='S') card[0][b-1]=1;
        else if(s=='H') card[1][b-1]=1;
        else if(s=='C') card[2][b-1]=1;
        else if(s=='D') card[3][b-1]=1;
    }
    char c;
    for(int i=0;i<4;i++){
		if(i == 0)      c = 'S';
		else if(i == 1) c = 'H';
		else if(i == 2) c = 'C';
		else if(i == 3) c = 'D';
		
		for(int j=0;j<13;j++){
			if(card[i][j] == 0){
				cout<<c<<" "<<j+1<<endl;
			}
		}
	}

}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};

ll x[50], y[50];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  ll result = -1;
  for (int i0 = 0; i0 < n; i0++) {
    for (int i1 = i0; i1 < n; i1++) {
      for (int i2 = i1; i2 < n; i2++) {
        for (int i3 = i2; i3 < n; i3++) {
          auto x0 = min(min(x[i0], x[i1]), min(x[i2], x[i3]));
          auto x1 = max(max(x[i0], x[i1]), max(x[i2], x[i3]));
          auto y0 = min(min(y[i0], y[i1]), min(y[i2], y[i3]));
          auto y1 = max(max(y[i0], y[i1]), max(y[i2], y[i3]));
          int c = 0;
          for (int i = 0; i < n; i++) {
            if (x0 <= x[i] && x[i] <= x1 && y0 <= y[i] && y[i] <= y1) {
              c++;
              if (c >= k) break;
            }
          }
          if (c >= k) {
            auto s = (x1 - x0) * (y1 - y0);
            result = result == -1 ? s : min(result, s);
          }
        }
      }
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc179/abc179_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    D = [False for _ in range(N)]
    for i in range(N):
        a, b = i2nn()
        if a == b:
            D[i] = True
            if i >= 2 and all(D[i-2:i+1]):
                print('Yes')
                return
    print('No')
    return

main()


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

struct Interval {
  int l;
  long long w;
  Interval(int l, long long w) : l(l), w(w) {}
  bool operator<(const Interval& oth) const { return l < oth.l; }
};


struct Seg {
  int l, m, r;
  Seg* ch[2] = {};
  long long mi = 0, tag = 0;
  void pull() {
    mi = min(ch[0]->mi, ch[1]->mi);
  }
  void push() {
    if (tag) {
      for (int i : {0, 1}) ch[i]->tag += tag, ch[i]->mi += tag;
      tag = 0;
    }
  }
  Seg(int l, int r) : l(l), r(r), m(l + r >> 1) {
    if (r - l > 1) {
      ch[0] = new Seg(l, m);
      ch[1] = new Seg(m, r);
    }
  }
  void add(int ql, int qr, long long v) {
    if (ql == qr) return;
    if (ql <= l and r <= qr) mi += v, tag += v;
    else {
      push();
      if (ql < m) ch[0]->add(ql, qr, v);
      if (m < qr) ch[1]->add(ql, qr, v);
      pull();
    }
  }
  long long query(int ql, int qr) {
    if (ql <= l and r <= qr) return mi;
    else {
      long long ans = 0;
      push();
      if (ql < m) ans = min(ans, ch[0]->query(ql, qr));
      if (m < qr) ans = min(ans, ch[1]->query(ql, qr));
      pull();
      return ans;
    }
  }
};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, m; cin >> n >> m;
  vector<vector<Interval>> lb(n + 1);
  long long sum = 0;
  for (int i = 0; i < m; ++i) {
    int l, r, w; cin >> l >> r >> w;
    sum += w;
    lb[r].emplace_back(l - 1, w);
  }
  for (int i = 0; i <= n; ++i) sort(lb[i].begin(), lb[i].end());
  Seg dp(0, n + 1);
  for (int r = 1; r <= n; ++r) {
    dp.add(r, r + 1, dp.query(0, r));
    for (auto I : lb[r]) {
      dp.add(0, I.l + 1, I.w);
    }
  }
  cout << sum - dp.query(0, n + 1) << '\n';
}


Measured memory_bytes: 36224
i = 1
while i <= 5:
    x = int(input())
    if x == 0:
        break
    y = 1000 - x
    c_1 = y//500
    c_2 = y%500//100
    c_3 = y%500%100//50
    c_4 = y%500%100%50//10
    c_5 = y%500%100%50%10//5
    c_6 = y%500%100%50%10%5//1
    print(c_1+c_2+c_3+c_4+c_5+c_6)


Measured memory_bytes: 5588
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define maxl __LONG_LONG_MAX__
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define rep(i, n) for(int i = 0; i < n; i++)
#define rev(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i=1; i < n; i++)
#define rev1(i, n) for(int i=n ; i > 0; i--)
#define FOR(i, a, b) for(int i=a ; i < b; i++)

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef stack<ll> stk;
typedef queue<ll> que;
typedef map<ll,ll>::iterator mit;
typedef set<ll>::iterator sit;
typedef vector<ll>::iterator vit;

ll mod = 1e9 + 7;

void solve()
{
	ll n;
	cin>>n;
	vll a(n+1), b(n+1), c(n+1);
	rep1(i, n+1)
		cin>>a[i]>>b[i]>>c[i];
	vvll dp(n+1, vll (3, 0));
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	for(ll i = 2; i <= n; i++)
	{
		dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][1], dp[i-1][0]);
	}
	cout<<max({dp[n][0], dp[n][1], dp[n][2]})<<endl;
	return;
}


int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	ll t = 1;
	//cin>>t;
	rep(i, t)
	{
		solve();
	}
	return 0;	
}

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

int main(){
    int r,g,b;
    cin >> r >> g >> b;

    if((100*r + 10*g +b) % 4 == 0){
        cout << "YES" <<endl;
    }else{
        cout << "NO" <<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
// Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n, k;
    cin >> n >> k;
    vector<Int> s;
    map<Int, Int> mp;
    for (Int i = 0; i < n; i++) {
        Int t, d;
        cin >> t >> d;
        if (mp[t] > 0) {
            if (mp[t] < d) {
                swap(mp[t], d);
            }
        }
        else {
            mp[t] = d;
            continue;
        }
        s.emplace_back(d);
    }
    sort(s.begin(), s.end(), greater<Int>());
    vector<Int> t;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) t.emplace_back(itr->second);
    sort(t.begin(), t.end(), greater<Int>());
    for (Int i = 0; i < (Int)s.size() - 1; i++) s[i + 1] += s[i];
    for (Int i = 0; i < (Int)t.size() - 1; i++) t[i + 1] += t[i];
   /*  for (Int i = 0; i < (Int)s.size(); i++) cout << s[i] << " ";
    cout << '\n';
    for (Int i = 0; i < (Int)t.size(); i++) cout << t[i] << " ";
    cout << '\n'; */
    Int res = 0;
    for (Int i = 0; i < (Int)t.size(); i++)  {
        if (k - i - 2 < -1 || k - i - 2 >= (Int)s.size()) continue;
        Int ma = 0;
        if (k - i - 2 == -1) {
            ma = t[i] + (i + 1) * (i + 1);
        }
        else {
            ma = t[i] + s[k - i - 2] + (i + 1) * (i + 1);
        }
        res = max(res, ma);
    }
    dump(res);
    return 0;  
} 

Measured memory_bytes: 7676
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
using namespace std;

signed main()
{
    fast;
    int x;
    cin>>x;

    int v = x/500;
    int m = x%500;

    int ans = 0;
    ans += 1000*v;

    int l = m/5;
    ans += l*5;

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int N;
int h[1000001],f[1000001];
int main () {
	cin>>N;
	for(int i=1;i<=N;i++) {
		scanf("%d",&h[i]);
	}
	f[1]=0;
	f[2]=abs(h[2]-h[1]);
	for(int i=3;i<=N;i++) {
		f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<f[N];
	return 0; 
}

Measured memory_bytes: 4736
N,M=map(int,input().split())
def bikkuri(A):
    ans=1
    for i in range(A):
        ans*=i+1
        ans%=1000000007
    return ans

if N==M:
    p=2*(bikkuri(N)*bikkuri(M)%1000000007)
    p%=1000000007
elif  abs(N-M)==1:
    p=(bikkuri(M)*bikkuri(N)%1000000007)
    p%=1000000007
else:
    p=0
print(p)


Measured memory_bytes: 3060
#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, 0};
int dx[]={1, -1, 0, 0, 0};

int main()
{
int a,b,h;
cin>>a>>b>>h;
cout<<(a+b)*h/2<<endl;
}

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

int main(){
  char buf[10];
  int n,cnt=0;
  cin >> n;
  for (int i=0;i<n;i++){
    cin >> buf;
    if (buf[0]=='A'){
      cnt++;
    }else{
      if (cnt==0){
	cout << "NO" << endl;
	return 0;
      }else{
	cnt--;
      }
    }
  }
  if (cnt==0) cout << "YES"<< endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3060
n,l = map(int,input().split())
t = []
ans = []
w = []
diff = []

for i in range(n):
    t.append(l+(i+1)-1)

for i in range(n):
    ans = t.copy()
    del ans[i]
    w.append(sum(ans))
    diff.append(abs(sum(t)-sum(ans)))

num = diff.index(min(diff))

print(w[num])




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e8;

int main(){
  int H,W; cin >> H >> W;
  int black = 0;
  vector<vector<char>> maze(H,vector<char>(W));
  rep(i,H)rep(j,W) {
    cin >> maze[i][j];
    if(maze[i][j] == '#') black++;
  };
  //search
  queue<pair<int,int>> que;
  int dx[] = {0,1,0,-1};
  int dy[] = {1,0,-1,0};
  vector<vector<int>> dist(H,vector<int>(W,INF));
  dist[0][0] = 1;
  que.push({0,0});
  while(!que.empty()){
    auto v = que.front();que.pop();
    rep(i,4){
      int next_y = v.first+dy[i];
      int next_x = v.second+dx[i];
      if(next_y < 0 || next_y >= H || next_x < 0 || next_x >= W || maze[next_y][next_x] == '#') continue;
      if(dist[next_y][next_x] != INF) continue;
      dist[next_y][next_x] = dist[v.first][v.second] + 1;
      que.push({next_y,next_x});
    }
  }
  ll ans = H*W - dist[H-1][W-1] - black;
  if(dist[H-1][W-1] == INF) cout << -1 << endl;
  else cout << ans << endl; 
}

Measured memory_bytes: 256
S = input()
N = len(S) + 1

ans = [0] * N
for i in range(N - 1):
    if S[i] == '<':
        ans[i + 1] = ans[i] + 1
for i in range(N - 1):
    if S[N - i - 2] == '>' and ans[N - i - 2] <= ans[N - i - 1]:
        ans[N - i - 2] = ans[N - i - 1] + 1

print(sum(ans))


Measured memory_bytes: 23372
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

def func(a, b):
    if a > b:
        return 0
    else:
        return 1

def solvedp(arr, ii):
    dp = [[0, 0] for _ in range(ii)]
    lenarr = len(arr)
    if ii == l:
        n0 = int(n[0])
        a = lenarr
        for j in range(lenarr):
            a -= func(n0, arr[j])
        dp[0][0] = a
        dp[0][1] = 1 if n0 in arr else 0
    else:
        dp[0][0] = lenarr
    for i in range(1, ii):
        if ii == l:
            ni = int(n[i])
            a = lenarr
            for j in range(lenarr):
                a -= func(ni, arr[j])
            dp[i][0] = dp[i-1][0] * lenarr + dp[i-1][1] * a
            dp[i][1] = dp[i-1][1] if ni in arr else 0
        else:
            dp[i][0] = dp[i-1][0] * lenarr
    return dp

n = STR()
l = len(n)
ans = 0

arr = [[3], [5], [7], [3, 5], [5, 7], [7, 3], [3, 5, 7]]
for ii in range(1, l + 1):
    dp = [[[0, 0]for _ in range(ii)]for _ in range(7)]
    for i in range(7):
        dp[i] = solvedp(arr[i], ii)

    res = sum(dp[6][ii-1])
    for i in range(3, 6):
        res -= sum(dp[i][ii-1])
    for i in range(3):
        res += sum(dp[i][ii-1])
    ans += res
print(ans)


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

using namespace std;

int N, A, B, nr, st[4017];
string ans;

bool query (int x, int y)
{
    x --, y --;
    printf ("? %d %d\n", x, y);
    fflush (stdout);
    char rd[4];
    scanf ("%s", rd);
    return (rd[0] == 'Y');
}

int main ()
{
scanf ("%d %d", &A, &B), N = A + B;
if (A <= B)
{
    printf ("Impossible\n");
    fflush (stdout);
    return 0;
}
nr = 0;
for (int i=1; i<=N; i++)
    if (nr == 0) st[++nr] = i;
    else
    if (query (st[nr], i)) st[++nr] = i;
    else nr --;
for (int i=1; i<=N; i++)
    if (i != st[nr]) ans.push_back ((char) ('0' + query (st[nr], i)));
    else ans.push_back ('1');
printf ("! %s\n", ans.c_str ());
fflush (stdout);
return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#define For(i, l, r) for (int i = l; i <= r; ++ i)
using namespace std;

const int N = 2e2 + 10;
int n, a[N], ans;

int main() {
	scanf("%d", &n);	
	int t = n << 1;
	For(i, 1, t) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + t);	
	For(i, 1, n) ans += a[i - 1 << 1 | 1];
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define MAX 15
#define INF 1e9

int N;
int G[MAX][MAX],bit;
int len[MAX];
int dp[1<<MAX][MAX];
string s[MAX];

int calc(int a,int b){
  string s1 = s[a],s2 = s[b];
  int l1 = len[a],l2 = len[b];

  if(s2.find(s1) != string::npos &&
     s1.find(s2) == string::npos){
    bit |= (1<<a);
    return 0;
  }else if(s1.find(s2) != string::npos &&
           s2.find(s1) == string::npos){
    bit |= (1<<b);
    return 0;
  }
  
  for(int i = min(l1,l2) ; i >= 0 ; i--){
    string subs1 = s1.substr(l1-i,i);
    string subs2 = s2.substr(0,i);
    if(subs1 == subs2){
      return subs1.size();
    }
  }
  return 0;
}

int solve(int S,int v){
  if(S == (1<<N)-1) return 0;
  if(dp[S][v] != -1) return dp[S][v];
  int res = INF;
  for(int i = 0 ; i < N ; i++){
    if((S >> i) & 1) continue;
    res = min(res,solve(S|(1<<i),i)+len[i]-G[v][i]);
  }
  return dp[S][v] = res;
}

int main(){
  while(cin >> N,N){
    bit = 0;
    memset(dp,-1,sizeof(dp));
    fill(G[0],G[0]+MAX*MAX,INF);
    for(int i = 0 ; i < N ; i++){
      cin >> s[i];
      len[i] = s[i].size();
    }
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(i == j) continue;
        G[i][j] = calc(i,j);
      }
    }
    int res = INF;
    for(int i = 0 ; i < N ; i++){
      if((bit >> i) & 1) continue;
      res = min(res,solve(bit|(1<<i),i)+len[i]);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3144
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] inputAB = scan.nextLine().split(" ");
        Integer a = Integer.valueOf(inputAB[0]);
        Integer b = Integer.valueOf(inputAB[1]);

        List<Integer> results = new ArrayList<Integer>();
        results.add(a + b);
        results.add(a - b);
        results.add(a * b);
        results.sort(Comparator.reverseOrder());

        System.out.println(results.get(0));
        scan.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  string op;
  cin >> a >> b;
 
  if (a * b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}


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

using namespace std;

struct code
{
    string str;

} pari[105];

bool cmp(code c1, code c2)
{
    return c1.str<c2.str;
}

int main()
{
    int n,l;

    while(scanf("%d %d",&n,&l)==2)
    {
        for(int i=0; i<n; i++)
        {
            cin>>pari[i].str;
        }

        sort(pari, pari+n, cmp);

        for(int i=0; i<n; i++)
        {
            cout<<pari[i].str;
        }

        printf("\n");
    }

    return (0);
}


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

using namespace std;

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

		int a, b, c, d,startTime,endTime,result;
		cin >> a >> b >> c >> d;
		
		startTime = max(a, c);
		endTime = min(b, d);
		result= endTime - startTime;

		if (result < 0) {
			cout << 0;
		}
		else {
			cout << result;
		}


		return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main{
  static int n, m;
  static List< List< Integer > > graph;

  static int count;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    m = sc.nextInt();
    graph = new ArrayList< >(n);
    for(int i = 0; i < n; i++){
      graph.add(new ArrayList< >());
    }
    for(int i = 0; i < m; i++){
      int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
      graph.get(a).add(b);
      graph.get(b).add(a);
    }

    count = 0;
    backTrack(0, 0, new boolean[n]);

    System.out.println(count);
  }

  static void backTrack(int i, int v, boolean[] visited){
    if(i == n - 1){
      ++count;
      return;
    }
    visited[v] = true;
    for(int w : graph.get(v)){
      if(!visited[w]){
        backTrack(i + 1, w, visited);
      }
    }
    visited[v] = false;
  }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
 
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int a,b,k;cin>>k>>a>>b;
        for(int i=a;i<=b;i++){
            if(i%k==0){
                cout<<"OK";return 0;
            }
        }
        cout<<"NG";return 0;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<string>

int main()
{
    int A, B, sum=0;
    
    std::cin >> A >> B;
    
    for(int i=A; i<=B; i++)
    {
        std::string str = std::to_string(i);
        if(str[0]==str[4]&&str[1]==str[3])
            sum++;
    }
    
    std::cout << sum << std::endl;
    return 0;
}


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

vector<int> A(200001, 0);

void So(int x) {
	if (x == 1) return;
	A[0]++;
	int y = sqrt(x);
	for (int i = 2;i <= y;i++) {
		if (x % i == 0) {
			A[i - 1]++;
			if (i*i != x)
				A[x / i - 1]++;
		}
	}
}

int main() {
	int N, M = 0;
	cin >> N;

	for (int i = 0;i < N;i++)
		cin >> A[i];

	for (int i = N - 1;i >= 0;i--) {
		A[i] %= 2;
		if (A[i]) {
			M++;
			So(i + 1);
		}
	}
	cout << M << endl;
	for (int i = 0;i < N;i++) {
		if (A[i]) {
			cout << i + 1;
			if (i != N - 1)cout << " ";
		}
	}
	if (M > 0) cout << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main( )
{
  int i, j, temp,count=0;
  int A[100],N;
  scanf("%d",&N);
  for(i=0; i < N; i++){
    scanf("%d",&A[i]);
  }
  for(i=0; i < N-1; i++){
    for(j = N-1; j > i; j--){
      if(A[j]<A[j-1]){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	count++;
      }
    }
  }
  for(i = 0; i < N ; i++){
    if(i == N-1){
      printf("%d",A[i]);
    }
   else printf("%d ",A[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int M = 1000000007;

/*
   べき乗
   x^n mod M
   */
typedef unsigned long long ull;
ull power(ull x, ull n, ull M){
    ull res = 1;
    if(n > 0){
        res = power(x, n / 2, M);
        if(n % 2 == 0) res = (res * res) % M;
        else res = (((res * res) % M) * x ) % M;
    }
    return res;
}

//階乗
ull fac[200005] = {0};
ull factorial(int n, ull M){
    if(fac[n] != 0) return fac[n];
}

/*
   nCr コンビネーション
   (1,1)から(w,h)だと、引数は(w - 1, h - 1, M)
   */
ull combination(ull w, ull h, ull M){
    //nCr = n! / ( (n - r)! * r! )
    ull a = factorial(w + h, M);
    ull b = factorial(h, M) * factorial(w, M) % M;
    return a * power(b, M - 2, M) % M;
}

int main(){
    ull h, w, a, b;
    cin >> h >> w >> a >> b;

    fac[0] = fac[1] = 1;
    range(i,2,w + h + 1){
        fac[i] = fac[i - 1] * i % M;
        assert(fac[i] >= 0);
        assert(fac[i] <= M);
    }

    ull sum = 0;
    range(i,b,w){
        ull x = combination(i, h - a - 1, M);
        ull y = combination(w - i - 1, a - 1,M);
        sum += (x * y) % M;
    }
    cout << sum % M << endl;
}


Measured memory_bytes: 1792