akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
double cmin(double x, double y){
  if ( x > y){
    return y;
  }else{
    return x;
  }
  return 0;
}
int main(){
  double N, T, A;
  double ans = 10000000000;
  double H[1000];
  double Temp[1000];
  pair<double, int > Tm[1000];
  cin >> N >> T >> A;
  for(int i = 0; i < N; i++){
    cin >> H[i];
    Temp[i] = T - H[i] * 0.006;
    Tm[i].first = fabs(Temp[i] - A), Tm[i].second = i;
    ans = cmin(ans, Tm[i].first);
  }
  for(int i = 0; i < N; i++){
    if(ans == Tm[i].first){
      cout << Tm[i].second + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
def mips():
    return map(int,input().split())
def ii():
    return int(input())
T = input()
t = len(T)
ans = ""
for i in range(t-1):
    if T[i] == "?":
        if i == 0:
            if T[i+1] == "D":
                ans += "P"
            else:
                ans += "D"
        else:
            if T[i-1] == "D" and T[i+1] == "?":
                ans += "P"
                continue
            else:
                ans += "D"
    else:
        ans += T[i]
if T[-1] == "?":
    ans += "D"
else:
    ans += T[-1]
print(ans)

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

typedef pair<int, int> PII;

int solve(int n, int m, const vector<vector<int> > edges) {
  priority_queue<PII, vector<PII>, greater<PII> > pq;
  vector<bool> visited(n, false);

  int sum = 0;
  pq.push(make_pair(0, 0));
  
  while(!pq.empty()) {
    auto top = pq.top(); pq.pop();
    auto node = top.second;
    if (!visited[node]) {
      visited[node] = true;
      sum += top.first;
      
      for (auto i = 0; i < n; i++) {
	auto cost = edges[node][i];
	if (cost > 0) pq.push(make_pair(cost, i));
      }
    }
  }
  
  return sum;
}

int main() {
  int n;
  while(cin >> n, n) {
    int m;
    cin >> m;

    vector<vector<int> > street(n, vector<int>(n));

    for (auto i = 0; i < m; i++) {
      int a, b, d;
      scanf("\n%d,%d,%d", &a, &b, &d);
      d /= 100;
      d -= 1;
      street[a][b] = d;
      street[b][a] = d; 
    }

    cout << solve(n, m, street) << endl;
  }
  return 0;
}


Measured memory_bytes: 3408
#include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000000000000000
int main() {
	//freopen("input.txt", "r", stdin);
	int x, y;
	cin >> x >> y;
	if (y % 2 == 1) {
		cout << "No";
	} else {
		if (y >= 2 * x && y <= 4 * x) {
			cout << "Yes";
		}
		else
			cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
ll a[3001][3001];
int main()
{  
    FAST
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[0][i];
    }
    for(ll i=1;i<n;i++)
    {
        for(ll j=0;j<(n-i);j++)
        {
            a[i][j]=max((a[0][j+i]-a[i-1][j]),(a[0][j]-a[i-1][j+1]));
        }
    }
    cout<<a[n-1][0];
}

Measured memory_bytes: 70016
import java.util.Scanner;

public class Main {

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

		int input = reader.nextInt();

		int basePrice = input * 800;
		int change = input / 15 * 200;
		int finalPrice = basePrice - change;

		System.out.println(finalPrice);

		reader.close();
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6;
long double a[N];


int32_t main()
{
  int a,b,c; cin>>a>>b>>c;
  int ans=max(0LL,c-a+b);
  cout<<ans<<endl;
    return 0;
}

                        

                            

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var KN = ReadLineIntSplit();
			int K = KN[0];
			int N = KN[1];
			var A = ReadLineIntSplit();

			int maxDistance = 0;
			
			// 2の家の間の最大距離を求める
			for (int i = 0; i < N - 1; i++)
			{
				int btwHouse = A[i + 1] - A[i];
				if (btwHouse > maxDistance)	maxDistance = btwHouse;
			}

			int ftl = K - A[N - 1] + A[0];
			if (ftl > maxDistance)	maxDistance = ftl;

			Console.WriteLine(K - maxDistance);

		}
		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n-1, m-1) / m;
		}

		public static string ReadLine()
		{
			return Console.ReadLine();
		}

		public static int ReadLineInt()
		{
			return int.Parse(ReadLine());
		}

		public static string[] ReadLineStringSplit(char s=' ')
		{
			return ReadLine().Split(s).ToArray();
		}

		public static int[] ReadLineIntSplit(char s=' ')
		{
			return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray();
		}

		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 34780
a=input()
A=int(a.split()[0])
B=int(a.split()[1])
K=int(a.split()[2])

a=0
if(A>B): i=A
else: i=B
count=0
while(a==0):
  if(A%i==0 and B%i==0):
    count+=1
    if(count==K):
      print(i)
      break
  i-=1

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#define N (5000000+1000)
#define MOD (1000000007)
using namespace std;

long long n,k,fac[N],inv[N],facinv[N],f[2010][2010];

void Init()
{
	fac[0]=inv[1]=facinv[0]=1;
	for (int i=1; i<=5000000; ++i)
	{
		if (i!=1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		fac[i]=fac[i-1]*i%MOD; 
		facinv[i]=facinv[i-1]*inv[i]%MOD;
	}
}

long long C(long long n,long long m)
{
	if (m>n) return 0;
	return fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;
}

int main()
{
	Init();
	scanf("%lld%lld",&n,&k);
	if (k==1){printf("1"); return 0;}
	f[0][1]=1;
	for (int i=2; i<=n; ++i)
		f[0][i]=f[0][i-1]*C(i*(k-1)-1,k-2)%MOD;
	for (int i=1; i<=n; ++i)
		for (int j=i; j<=n; ++j)
			f[i][j]=(f[i-1][j]+f[i][j-1]*C(i+j*(k-1)-1,k-2)%MOD)%MOD;
	printf("%lld",f[n][n]*fac[n]%MOD);
}
 

Measured memory_bytes: 149120
import java.util.Scanner;

public class Main 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		while(true)
		{
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0)return;
			
			int[] p1 = new int[n];
			int[] p2 = new int[m];
			
			int s1 = 0;
			int s2 = 0;
			
			for(int i = 0; i < n; i++)
			{
				p1[i] = sc.nextInt();
				s1 += p1[i];
			}
			
			for(int i = 0; i < m; i++)
			{
				p2[i] = sc.nextInt();
				s2 += p2[i];
			}
			
			int ans1 = 999;
			int ans2 = 999;
			for(int c1 = 0; c1 < n; c1++)
			{
				for(int c2 = 0; c2 < m; c2++)
				{
					int card1 = p1[c1];
					int card2 = p2[c2];
					if(s1 - card1 + card2 == s2 - card2 + card1 && card1 + card2 < ans1+ans2)
					{
						ans1 = card1;
						ans2 = card2;
					}
				}
			}
			
			if(ans1 == 999 && ans2 == 999)
			{
				System.out.println(-1);
			}
			else
			{
				System.out.println(ans1 + " " + ans2);
			}
		}
	}

}



Measured memory_bytes: 29036
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int main(){
  int n;
  int i,j;
  int *A;
  int mini;
  int count=0;
  int swap;
  
  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  for(i=0;i<n;i++){
    mini=i;
    for(j=i;j<n;j++){
      if(A[j] < A[mini]) mini=j;
    }
    if(i!=mini){
      swap=A[i];
      A[i]=A[mini];
      A[mini]=swap;
      count+=1;
    }
  }
  
  printf("%d",A[0]);
  for(i=1;i<n;i++) printf(" %d",A[i]);
  printf("\n%d\n",count);
  return 0;
}


Measured memory_bytes: 2040
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp(" %s = %s\n", #x, to_string(x).data())
#define dbg_al(s, x) for(auto e:x)s+=to_string(e)+" "
#define dbg_rt(x) string s="[ ";dbg_al(s,x);s+="]";return s;
#define dbg_fd1 template<typename T>string to_string
#define dbg_fd2 template<typename U, typename V>string to_string
#define dbg_d1(c) dbg_fd1(c<T>);
#define dbg_d2(c) dbg_fd2(c<U, V>);
#define dbg_f1(c) dbg_fd1(c<T> v){dbg_rt(v);}
#define dbg_f2(c) dbg_fd2(c<U, V> v){dbg_rt(v);}
string to_string (char s) { return "\'"+string(1, s)+"\'"; }
string to_string (string s) { return "\"" + s + "\""; }
dbg_d1(vector) dbg_d1(set) dbg_d2(map)
dbg_fd2(pair<U, V> p) { return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
dbg_f1(vector) dbg_f1(set) dbg_f2(map)
/* ==================== */ 
const int N = 200010;
ll n, t[N], T;

int main() {
	scanf("%lld%lld", &n, &T);
	for (int i = 0; i < n; i++) scanf("%lld", &t[i]);
	ll ans = T;
	for (int i = 1; i < n; i++) ans += min(T, t[i] - t[i - 1]);
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
	char s[1000];
	int i,l,n,count=0;
	scanf("%s",&s);
	l=strlen(s);
	for(i=0;i<l-1;i=i+2)
	{
		if(s[i]=='h' && s[i+1]=='i')
		count++;
	}
	if(count== l/2 && l%2==0)
	printf("Yes");
	else
	printf("No");
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fr(i,a) for(ll i=0LL;i<a;i++)
#define fab(i,a,b) for(ll i=a;i<=b;i++)
#define fba(i,a,b) for(ll i=b;i>=a;i--)
#define rf(i,a) for(ll i=a;i>=0;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 10000000007
#define MAX 10000007
#define endl "\n"
#define ui unsigned int
#define ull unsigned long long int
#define ll long long int
#define V1 vector<ll>v
#define V2 vector<int>v
#define VP1 vector<pair<ll,ll>> vp
#define VP2 vector<pair<int,int>>vp
#define pb push_back

ll dp[MAX];
ll mod(ll a,ll b)
{
    return a>b ? a-b : b-a;
}

ll frog2(ll i,ll h[],ll k)
{
   ll j,minn=MX;
   if(i<0)
   return 0;
   if(dp[i]!=-1)
   return dp[i];
   else
   {
   fab(j,1,k)
   {
       if((i-j)>0)
       minn=min(minn,mod(h[i],h[i-j])+frog2(i-j,h,k));
       else
       minn=mod(h[i],h[0])+frog2(i-j,h,k);
   }
   dp[i]=minn;
   return dp[i];
   }
}


int main() {
	sup;
	ll n,k,cost;
	cin>>n>>k;
	ll h[n];
	fr(i,n)
	    cin>>h[i];
	for(ll i=0LL;i<MAX;i++)
    dp[i]=-1;
	cost=frog2(n-1,h,k);
	cout<<cost<<endl;
	return 0;
}


Measured memory_bytes: 87040
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] Az = new int[N];
        for (int i = 0; i < N; i++){
            Az[i] = sc.nextInt();
//            System.out.println(Az[i]);
        }
//        System.out.println("rr");
        int Q = sc.nextInt();
        int[] Bz = new int[Q + 1];
        int[] Cz = new int[Q + 1];
        for (int i = 0; i < Q; i++){
            Bz[i] = sc.nextInt();
            Cz[i] = sc.nextInt();
        }

        Arrays.sort(Az);
        long sumA = 0;
//        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        int[] nums = new int[1000001];
//        System.out.println("a");
        for (int i = 0; i < N; i++){
//            System.out.println(Az[i]);
            sumA += Az[i];
            nums[Az[i]]++;
        }
//        System.out.println("b");

        int changeNumCnt = 0;
//        int left = 0; int right = Az.length();
//        int mid = 0;
        int diff = 0;
//        System.out.println("sumA "+sumA);
        for (int i = 0; i < Q; i++){
            changeNumCnt = nums[Bz[i]];
            nums[Bz[i]] = 0;
            nums[Cz[i]] += changeNumCnt;
            diff = Cz[i] - Bz[i];
            sumA = sumA + (diff * changeNumCnt);
            System.out.println(sumA);
        }


    }
}

Measured memory_bytes: 69040
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=105;
int n,m;
int dp[MAXN][MAXN][MAXN],E[2];
int sumr[MAXN][MAXN],sumc[MAXN][MAXN];
int ori[MAXN][MAXN];
int main()
{
	//freopen("robot.in","r",stdin);
	//freopen("robot.out","w",stdout);
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("\n");
		for(int j=1;j<=m;j++)
		{
			char C;
			scanf("%c",&C);
			if(C=='o')
				ori[i][j]=1;
			if(C=='E')
			{
				E[0]=i;
				E[1]=j;
			}
			sumr[i][j]=sumr[i][j-1]+ori[i][j];
			sumc[i][j]=sumc[i-1][j]+ori[i][j];
		}
	}
	int L,R,U,D,ans=0;
	L=E[1]-1;
	R=m-E[1];
	U=E[0]-1;
	D=n-E[0];
	memset(dp,-1,sizeof(dp));
	dp[0][0][0]=0;
	for(int l=0;l<=L;l++)
	{
		for(int r=0;r<=R;r++)
		{
			for(int u=0;u<=U;u++)
			{
				for(int d=0;d<=D;d++)
				{
					if(dp[r][u][d]==-1)
						continue;
					ans=max(dp[r][u][d],ans);
					int up=max(E[0]-u,d+1);
					int down=min(E[0]+d,n-u);
					int left=max(E[1]-l,r+1);
					int right=min(E[1]+r,m-l);
					if(up>down||left>right)
						continue;
					int add=0;
					if(u<U-d)
					{
						add=sumr[E[0]-u-1][right]-sumr[E[0]-u-1][left-1];
						dp[r][u+1][d]=max(dp[r][u+1][d],dp[r][u][d]+add);
					}
					if(d<D-u)
					{
						add=sumr[E[0]+d+1][right]-sumr[E[0]+d+1][left-1];
						dp[r][u][d+1]=max(dp[r][u][d+1],dp[r][u][d]+add);
					}
					if(r<R-l)
					{
						add=sumc[down][E[1]+r+1]-sumc[up-1][E[1]+r+1];
						dp[r+1][u][d]=max(dp[r+1][u][d],dp[r][u][d]+add);
					}
					if(l<L-r)
					{
						add=sumc[down][E[1]-l-1]-sumc[up-1][E[1]-l-1];
						dp[r][u][d]=max(dp[r][u][d],dp[r][u][d]+add);
					}
				}
			}
		}
	}
	printf("%d\n",ans);
	fclose(stdin);
	fclose(stdout);
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ll long long
#define mod7 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define queries ll t;cin>>t;while(t--)
using namespace std;


int main(){

    fast
	
	ll x,y,z;
	cin>>x>>y>>z;
	if(x==y && x!=z){
		cout<<"Yes";
	}else if(x==z && y!=z){
		cout<<"Yes";
	}else if(y==z && x!=y){
		cout<<"Yes";
	}else{
		cout<<"No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
using namespace std;
 int main(){
   int n; cin >> n; int p[n]; int exp=0; int sum=0;
   for(int i=0;i<n;i++) cin >> p[i]; 
   for(int i=0;i<n;i++){
     exp=max(exp,p[i]);
     sum+=p[i];
   }
   cout << sum-exp/2 <<endl;
 }

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

def compute_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

divs = compute_divisors(M)
divs.sort(reverse=True)

for div in divs:
    if M / div >= N:
        ans = div
        break

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

const int MAX_V = 100;
int V, E;
std::vector<int> G[MAX_V];
int used[MAX_V];
int isConnected[MAX_V][MAX_V];

bool bfs(int s){
    std::fill(used, used+V, 0);
    
    std::queue<int> q;
    q.push(s);
    used[s] = 1;
    
    while(!q.empty()){
        int u = q.front(); q.pop();

        REP(i, G[u].size()){
            int v = G[u][i];
            if(!used[v]){
                if(isConnected[v][s]){return true;}
                q.push(v);
                used[v] = 1;
                isConnected[s][v] = 1;
            }
        }
    }

    return false;
}

int main(){
    std::cin >> V >> E;

    REP(i, E){
        int u, v;
        std::cin >> u >> v;
        
        G[u].push_back(v);
    }

    bool f = false;
    REP(v, V){
        f |= bfs(v);
    }

    if(f){puts("1");}
    else{puts("0");}
}

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

ll f(ll n, ll mod){
    if(n < 0)   return 0;
    ll ret = (n+1)/mod * (mod/2) +  max(0ll, n-((n+1)/mod*mod+mod/2)+1);
    return ret;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans =  0;
    for(int i = 0; i < 60; i++){
        if((1ll<<i) > b)  break;
        ll num = f(b, 1ll<<(i+1)) - f(a-1, 1ll<<(i+1));
        if(num%2)   ans += 1ll<<i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import*
L,R=[],[]
B=t=0
Q,*E=open(0)
for e in E:
	if' 'in e:_,a,b=map(int,e.split());t=1-t;a*=2*t-1;c=heappushpop([L,R][t],a);heappush([R,L][t],-c);B+=b+a-c-c
	else:print(-L[0],B-L[0]*t)

Measured memory_bytes: 28648
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
constexpr int N_max = 200'000;
constexpr int Q_max = 200'000;
using large = long long;

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

    auto connected_from = vector<vector<int>>(n);
    auto addition_to = vector<large>(n);

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        connected_from[a].push_back(b);
        connected_from[b].push_back(a);
    }
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        p--;
        addition_to[p] += x;
    }

    auto pushed = vector<char>(n);
    auto pile = queue<int>();
    pile.push(0);
    pushed[0] = true;
    while (!pile.empty()) {
        int v = pile.front();
        pile.pop();
        for (auto c : connected_from[v]) {
            if (!pushed[c]) {
                addition_to[c] += addition_to[v];
                pile.push(c);
                pushed[c] = true;
            }
        }
    }

    for (int v = 0; v < n; v++) {
        auto cnt = addition_to[v];
        printf("%lld%c", cnt, (v == n - 1 ? '\n' : ' '));
    }
    return 0;
}


Measured memory_bytes: 16500
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> ans;
	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	while (n != 1) {
		int a = n / (-2);
		int b = n % (-2);
		if (b == -1) {
			b = 1;
			a++;
		}
		n = a;
		ans.push_back(b);
	}
	ans.push_back(1);
	for (size_t i = 0; i <ans.size(); ++i) {
		cout << ans[ans.size()-i-1];
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
vac = []
for i in range(N):
    vac.append(list(map(int, input().split())))

dp = [[0 for _ in range(3)] for _ in range(N+1)]   

for i in range(N):
    for j in range(3):
        for k in range(3):
            if(j == k):
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+vac[i][k])
print(max(dp[-1]))

Measured memory_bytes: 50120
import heapq
N, M = list(map(int, input().split()))
A = list(map(lambda x: -x, list(map(int, input().split()))))

heapq.heapify(A)

for m in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, -(-a//2))

print(-sum(A))


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF=1e18l+5;

int main()
{
    int n,W;
    cin >> n >> W;
    
    vector<ll> dp(100005,INF) ;
    dp[0]=0;
    
    for(int i=0;i<n;++i)
    {
        int v,w;
        cin >> w >> v;
        for(int j=100005-v;j>=0;--j)
        {
            dp[v+j]=min(dp[v+j],dp[j]+w);
        }
    }
    ll ans=0;
    for(ll i=0;i<100005;++i)
    {
        if(dp[i]<=W)
        ans=max(i,ans);
    }
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 4048
#include <stdio.h>
#include <string.h>

int main(){
  char w[10], t[1000], c = 0, i;
  scanf("%s", w);
  while(scanf("%s", t) && strcmp(t, "END_OF_TEXT") != 0){
    for(i = 0;i < strlen(t);i++) t[i] = 'A' <= t[i] && 'Z' >= t[i] ? t[i] - 'A' + 'a' : t[i];
    if(strcmp(t, w) == 0) c++;
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 544
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int ans=700;
  string S;
  cin>>S;
  rep(i,0,3){
    if(S[i]=='o')
      ans+=100;
    }
  cout<<ans;
  }


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

A = []

for n in range(N):
  if n == 0:
    A.append(0)
  elif S[n] == "C" and S[n-1] == "A":
    A.append(A[n-1] + 1)
  else:
    A.append(A[n-1])

A.insert(0, 0)

for i in range(Q):
  x, y = map(int, input().split())
  print(A[y] - A[x])

Measured memory_bytes: 6180
import java.util.*;

public class Main {

    static class Edge {
        int from, to;
        boolean tree;

        public Edge(int from, int to) {
            this.from = from;
            this.to = to;
        }

        public int other(int u) {
            return u == to ? from : to;
        }

        public void reverse() {
            int tmp = from;
            from = to;
            to = tmp;
        }
    }

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

        List<List<Edge>> edges = new ArrayList<>();
        for (int i = 0; i < N; i++) edges.add(new ArrayList<>());

        for (int i = 0; i < M; i++) {
            Edge e = new Edge(sc.nextInt() - 1, sc.nextInt() - 1);
            edges.get(e.from).add(e);
            edges.get(e.to).add(e);
        }

        if (M % 2 != 0) {
            System.out.println(-1);
            return;
        }

        LinkedList<Integer> queue = new LinkedList<>();
        queue.addFirst(0);
        Edge[] pred = new Edge[N];
        int[] children = new int[N];
        LinkedList<Integer> leaves = new LinkedList<>();

        while (!queue.isEmpty()) {
            int u = queue.pollLast();
            for (Edge e : edges.get(u)) {
                int v = e.other(u);
                if (v == 0 || pred[v] != null) continue;
                e.tree = true;
                pred[v] = e;
                queue.addFirst(v);
                children[u]++;
            }
            if (children[u] == 0) leaves.add(u);
        }

        boolean[] odd = new boolean[N];
        for (int u = 0; u < N; u++) {
            for (Edge e : edges.get(u)) {
                if (!e.tree && u == e.from) odd[u] = !odd[u];
            }
        }

        while (!leaves.isEmpty()) {
            int u = leaves.pollLast();
            if (u == 0) break;
            Edge e = pred[u];
            int p = e.other(u);
            if (odd[u]) {
                if (e.from != u) e.reverse();
                odd[u] = false;
            } else {
                if (e.from == u) e.reverse();
                odd[p] = !odd[p];
            }
            children[p]--;
            if (children[p] == 0) leaves.addLast(p);
        }

        for (int u = 0; u < N; u++) {
            for (Edge e : edges.get(u)) {
                if (u == e.from) {
                    System.out.println((u + 1) + " " + (e.to + 1));
                }
            }
        }
    }
}


Measured memory_bytes: 114040
#include<bits/stdc++.h>
#define mod 1000000007
#define MOD(x) ((x)%mod)
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n,k;
long long dp[2][100005];
long long sum[2][100005];
int now,last;
int main()
{
	scanf("%d%d",&n,&k);
	dp[last][0]=1; sum[last][0]=1;
	for(int i=1;i<=k;i++)
		sum[last][i]=MOD(sum[last][i-1]+dp[last][i]);
	for(int i=1;i<=n;i++)
	{
		now=!last;
		memset(dp[now],0,sizeof dp[now]);
		memset(sum[now],0,sizeof sum[now]);
		int a;
		scanf("%d",&a);
		for(int j=0;j<=k;j++)
		{
			if(j-a-1<0) dp[now][j]=sum[last][j];
			else dp[now][j]=MOD(sum[last][j]-sum[last][j-a-1]+mod);
			sum[now][j]=MOD(sum[now][j-1]+dp[now][j]);
		}
		last=now;
	}
	printf("%lld",dp[now][k]);
	return 0;
}



Measured memory_bytes: 3328
// Last Change: 04/25/2019 19:00:26.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  char X, Y;
  cin >> X >> Y;
  if (X > Y) {
    cout << '>' << endl;
  } else if (X < Y) {
    cout << '<' << endl;
  } else {
    cout << '=' << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
	int n;
	scanf("%d",&n);
	if(n!=1){
		int m_num=0;
		int m_time=0;
		for(int i=n;i>0;i--){
			if(i%2==0){
				int cnt=0;
				int mem=i;
				while(mem%2==0){
					mem/=2;
					cnt++;
				}
				if(cnt>m_time){
					m_time=cnt;
					m_num=i;
				}

			}
		}
		printf("%d\n",m_num);

	}
	else{
		printf("1\n");
	}
	return 0;
}

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


int count(int n, int k){
  int a = 0;
  while(n <= k-1){
    n *= 2;
    a++;
  }
  return a;
}

int main(){
  int n, k;
  cin >> n >> k;
  double half[50];
  half[0] = 1.0;
  rep(i, 49) half[i+1] = half[i]*0.5;
  double ans = 0.0;
  for(int i = 1; i <= n; i++){
    int c = count(i, k);
    ans += (1.0/(double)n)*half[c];
  }
  printf("%.15lf", ans);
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main()
{
	string x[1000];
	int n = 0;
	while (1)
	{

		cin >> x[n];
		if (x[n] == "0")
		{
			break;
		}
		n++;
	}
	long long total[1000];
	for (int i = 0; i < n; i++)
	{
		total[i] = 0;
		for (int j = 0; j < x[i].size(); j++)
		{
			//cout << x[i].substr(j, 1) << endl;
			total[i] += stoi(x[i].substr(j, 1));
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << total[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3196
#include <stdio.h>

int main(void)
{
	int t[4][14];
	int n, i, j, c;
	char m, d;

	for (i = 0; i < 4; i++){
		for(j = 0; j < 14; j++){
			t[i][j] = 0;
		}
	}

	scanf("%d", &c);
	
	for (i = 0; i <= c; i++){
		scanf("%c", &d);
		scanf("%c %d", &m, &n);

		if (m == 'S'){
			t[0][n] = 1;
		}
		else if (m == 'H'){
			t[1][n] = 1;
		}
		else if (m == 'C'){
			t[2][n] = 1;
		}
		else if (m == 'D'){
			t[3][n] = 1;
		}
	}

	for (j = 1; j < 14; j++){
		if (t[0][j] != 1){
			printf("S %d\n", j);
		}
	} 

	for (j = 1; j < 14; j++){
		if (t[1][j] != 1){
			printf("H %d\n", j);
		}
	} 

	for (j = 1; j < 14; j++){
		if (t[2][j] != 1){
			printf("C %d\n", j);
		}
	} 

	for (j = 1; j < 14; j++){
		if (t[3][j] != 1){
			printf("D %d\n", j);
		}
	} 

	return (0);
}



Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

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

// const ll INF = 1LL << 60;

int main()
{
  int N, M;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int x[200010];

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> x[i];

	vector<int> ary;
	rep(i,n) ary.push_back(x[i]);
	sort(begin(ary),end(ary));

	rep(i,n){
		const int idx = lower_bound(begin(ary),end(ary),x[i]) - begin(ary);
		if(idx < n/2)
			cout << ary[n/2] << endl;
		else
			cout << ary[n/2-1] << endl;
	}

	return 0;
}

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

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

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;

template<typename T>
map<T, ll> prime_factorize(T x){
  map<T, ll> res;

  while(x%2==0){
    x/=2;
    res[2]++;
  }

  for(ll i=3;i*i<=x;i+=2){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

int main(){
  cout << setprecision(10);
  ll N;
  cin >> N;
  auto m = prime_factorize(N);

  ll ans = 0;
  for(auto x: m){
    ll target = x.second;

    ll num;
    for(ll i = 1; i < 100; i++){
      if((i+1)*(i+2)/2 > target){
        num = i;
        break;
      }
    }
    ans += num;
  }
  cout << ans << endl;
}


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

const int N = 200005, P = 10005;

int n, p;
string s;

template <typename T>
T extend_gcd(T a, T b, T &x, T&y) {
    T t, ret;
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    } else {
        ret = extend_gcd(b, a % b, x, y);
        t = x;
        x = y;
        y = t - a / b * y;
        return ret;
    }
}

// ax = b(mod p)
int hao(LL a, LL b, LL p) {
    // cout << "FF " << a << ' ' << b << ' ' << p << '\n';
    LL d = __gcd(a, p);
    if (b % d) return -1;
    LL x, y;
    extend_gcd(a, p, x, y);
    return (x * b % p + p) % p;
}

LL gao() {
    LL ans = 0, a = 1, b = 0;
    if (p == 2 || p == 5) {
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0) ans += i + 1;
        }
        return ans;
    }

    vector<int> dp(p, 0);
    dp[(s[0] - '0') % p] = 1, ans += dp[0];
    for (int i = 1; i < s.size(); i++) {
        int id = (s[i] - '0') % p;
        a = 10 * a % p, b = (10 * b + id) % p;
        dp[hao(a, (id - b + p) % p, p)]++;
        ans += dp[hao(a, p - b, p)];

        // printf("i= %d a= %lld b= %lld\n", i, a, b);
        // for (int j = 0; j < dp.size(); j++) printf("j= %d %d\n", j, dp[j]);
    }
    return ans;
}

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    while (cin >> n >> p) {
        cin >> s;
        cout << gao() << '\n';
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
// const ll INF = 1000000000000000000;
const ll MOD = 1000000007;

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

	int n;
	cin>>n;
	int k = (1<<n);
	ll a[n][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];

	ll f[k];
	for(int i=0;i<k;i++){
		vector<int> v;
		for(int j=0;j<n;j++){
			if(i&(1<<j))
				v.pb(j);
		}

		f[i] = 0;
		for(int x: v)
			for(int y: v)
				f[i] += a[x][y];
	}

	ll dp[k];
	dp[0] = 0;
	for(int mask=1;mask<k;mask++){
		dp[mask] = f[mask];
		for(int sm=(mask-1)&mask;sm;sm = (sm-1)&mask)
			dp[mask] = max(dp[mask],dp[sm]+f[mask-sm]);
	}

	cout<<dp[k-1]/2<<endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define SP <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    bool win;
    while(true){
        c -= b;
        if(c <= 0){
            win = false;
            break;
        }
        a -= d;
        if(a <= 0) {
            win = true;
            break;
        }
    }
    
    if(win) CNO;
    else CYES;

}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  int N=S.size();
  int M=T.size();
  bool ff=false;
  for(int i=N-M;i>=0;i--){
    bool f=true;
    for(int j=0;j<M;j++){
      if(S[i+j]!='?'&&S[i+j]!=T[j]){
        f=false;
        break;
      }
    }
    if(f){
      for(int j=0;j<M;j++)S[i+j]=T[j];
      for(int j=0;j<N;j++)if(S[j]=='?')S[j]='a';
      ff=true;
      break;
    }
  }
  if(ff)cout<<S<<endl;
  else cout<<"UNRESTORABLE"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



map<int,int> c;
int a, m;

signed main() {
	while (scanf("%d",&a)!=EOF) c[a]++;
	each(i,c) chmax(m,i.second);
	each(i,c) if (i.second==m) cout << i.first << endl;
}


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

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

    int ans = 0;
    if(a * c < b){
        ans = c;
    }else{
        ans = b / a;
    }

    cout << ans << endl;

    return 0;

}

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

int main() {
    int a, b; std::cin >> a >> b;
    int c = a * std::pow(10, (int)(std::log10(b) + 1)) + b;
    int d = (int)(std::sqrt(c));
    std::cout << ((c == d * d)?"Yes":"No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>
#include<iomanip>

using namespace std;

typedef long long ll;

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

  if(abs(a - b) >= 1) cout << max(a, b) * 2 - 1 << endl;
  else cout << a * 2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i;
	char T[1000];
	char H[1000];
	int t=0, h=0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", T, H);
		if (strcmp(T, H) == 0)
			t++, h++;
		else if (strcmp(T, H) > 0)
			t += 3;
		else if (strcmp(T, H) < 0)
			h += 3;
	}
	printf("%d %d\n", t, h);
	return 0;
}


Measured memory_bytes: 2024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int read_xy(int *x, int *y)
{
    char line[256];
    memset(line, 0, sizeof(line));
    if (!fgets(line, sizeof(line), stdin)) {
        fprintf(stderr, "error input val\n");
        return -1;
    }

    if (sscanf(line, "%d %d", x, y) != 2) {
        fprintf(stderr, "error input format\n");
        return -1;
    }
    return 0;
}



int main(int argc, char *argv[])
{
    int x, y;
    while (1) {
        if (read_xy(&x, &y) < 0) {
            exit(1);
        }

        if (x == 0 && y == 0) {
            break;
        }

        if (x < y) {
            printf("%d %d\n", x, y);
        } else {
            printf("%d %d\n", y, x);
        }
    }

    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;
    int nt = n;
    int digits = 0;

    while(nt > 0){
        digits++;
        nt /= 10;
    }

    if(digits == 2){
        cout << 9;
    }
    else if(digits == 4){
        cout << 9 + 900;
    }
    else if(digits == 1){
        cout << n;
    }
    else if(digits == 3){
        cout << n - 100 + 1 + 9;
    }
    else if(digits == 5){
        cout << n - 10000 + 1 + 900 + 9;
    }
    else if(digits == 6){
        cout << 90909;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        ll n, m;
        cin >> n >> m;

        vector<ll> a(n);
        rep (i, n) cin >> a[i];

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

        vector<ll> c(n + 1, 0);
        rep (i, n) c[i + 1] = c[i] + a[i];

        auto f = [&](ll x) {
                ll t = 0;

                rep (i, n) {
                        int d = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
                        t += n - d;
                }

                return t >= m;
        };

        auto g = [&](ll x) {
                ll t = 0, s = 0;

                rep (i, n) {
                        int d = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
                        t += n - d;
                        s += (n - d) * a[i] + (c[n] - c[d]);
                }

                return s - x * (t - m);
        };

        ll l = 0, r = 1e10;
        while (r - l > 1) {
                ll m = (l + r) / 2;
                if (f(m)) {
                        l = m;
                } else {
                        r = m;
                }
        }

        cout << g(l) << endl;

        return 0;
}


Measured memory_bytes: 1792
def cross(x, y):
    return (x.conjugate() * y).imag
 
def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
     
     
import sys
 
p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(complex(x, y))
 
print(area_polygon(p))

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, W;
  cin >> n >> W;
  int v[100], w[100];
  rep(i, n) cin >> v[i] >> w[i];
  int dp[110][10010] = {};
  rep(i, n)
  {
    rep(j, W + 1)
    {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (j + w[i] <= W)
        dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
    }
  }
  int Max = 0;
  rep(j, W + 1) Max = max(Max, dp[n][j]);
  cout << Max << endl;
  return 0;
}



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

int main(void){
    int n, a, b, c, d;
    int sum1 = 0, sum2 = 0;
    int kane1 = 0, kane2 = 0;

    cin >> n >> a >> b >> c >> d;
    
    while(sum1 < n){
        sum1 += a;
        kane1 += b; 
    }
    while(sum2 < n){
        sum2 += c;
        kane2 += d;
    }
    if(kane1 < kane2){
        cout << kane1 << endl;
    }else{
        cout << kane2 << endl;
    }
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int A, B; cin >> A >> B;
  if (A == 1) A += 13;
  if (B == 1) B += 13;

  string ans;
  if (A > B) ans = "Alice";
  if (B > A) ans = "Bob";
  if (A == B) ans = "Draw";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,a,b;
  
  scanf("%lld",&k);
  scanf("%lld %lld",&a,&b);
  
  for(;a<=b;a++){
    if(a%k==0){
      result=1;
      break;
    }
  }
  if(result==1) printf("OK");
  else printf("NG");
  
  return 0;
}



Measured memory_bytes: 1728
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i,j):
	for t in r(30):b(p:=j+t-1);a(q:=j+t,n,q);[*map(b,r(q,j+29))];a(j+29,x,i+t,1);b(p);a(q,i+t,q)
p(3933)
a(0,1,n:=97)
a(2,n,n,1)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):a(2,2,2);[t-30<s<30!=(a(5+t-s,36+s,98),a(n,98,99,1),a(2,99,2))for s in r(t+1)]

Measured memory_bytes: 9192
import java.io.*;
import java.util.*;

class Lake {
	Lake(int area, int x){
		this.area = area;
		this.x = x;
	}
	public int area, x;
}

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		char g[] = br.readLine().toCharArray();
		int sum = 0;
		ArrayDeque<Integer> lx = new ArrayDeque<Integer>();
		ArrayDeque<Lake> lakes = new ArrayDeque<Lake>();

		for(int x = 0; x < g.length; x++) {
			if (g[x] == '\\') {
				lx.add(x);
			} else if (!lx.isEmpty() && g[x] == '/') {
				int a = x - lx.getLast();
				sum += a;
				while (!lakes.isEmpty() && lx.getLast() < lakes.getLast().x) {
					a += lakes.getLast().area;
					lakes.removeLast();
				}
				lakes.add(new Lake(a, lx.pollLast()));
			}
		}
		StringBuilder sb = new StringBuilder();
		sb.append(sum).append('\n').append(lakes.size());
		for (Lake l : lakes) {
			sb.append(' ').append(l.area);
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 25648