akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int costCheck(int n) {
    int cost;
    if (n < 10) {
        cost = 10 - n;
    } else {
        if (n % 10 != 0) {
            cost = 10 - (n % 10);
        } else {
            cost = 0;
        }
    }
    return cost;
}

int maxCostCheck(int a, int b) {
    if (a < b) {
        return b;
    } else {
        return a;
    }
}

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

    int costA = costCheck(a);
    int costB = costCheck(b);
    int maxCost = maxCostCheck(costA, costB);

    int costC = costCheck(c);
    maxCost = maxCostCheck(maxCost, costC);

    int costD = costCheck(d);
    maxCost = maxCostCheck(maxCost, costD);

    int costE = costCheck(e);
    maxCost = maxCostCheck(maxCost, costE);

    int ans = a + costA + b + costB + c + costC + d + costD + e + costE - maxCost;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int N, M;
vector <int> G[100001];
bool used[100001];
vector <int> ans;

void dfs(int v) {
  if(!used[v]) {
    used[v] = true;
    ans.push_back(v);
  }

  for(int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if(!used[u]) {
      dfs(u);
      break;
    }
  }
  
  return;
}

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

  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0);
  reverse(ans.begin(),ans.end());
  dfs(0);
  
  cout << ans.size()<<endl;

  for(int i = 0; i < ans.size(); i++) {
    cout << ans[i]+1 <<" ";
  }

  cout << endl;
}
				     


Measured memory_bytes: 9720
n = int(input())
taro = 0
hana = 0
for c in range(0,n):
    word = input().split(' ')
    taro_w, hana_w = word[0], word[1]
    word.sort()
    if word[0] == word[1]:
        taro += 1
        hana += 1
    elif taro_w == word[0]:
        hana += 3
    else:
        taro += 3
print("%d %d" % (taro, hana))

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

int a,b;
char grid[100][100];

int main()
{
  cin >> a >> b;
  a--, b--;
  cout << 100 << " " << 100 << endl;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      if (i < 50) {
        if (i % 2 == 0 && (i+j)%2 == 0 && b) {
          cout << '#';
          b--;
        } else {
          cout << '.';
        }
      } else {
        if (i % 2 == 1 && (i+j)%2 == 0 && a) {
          cout << '.';
          a--;
        } else {
          cout << '#';
        }
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
#include <complex>
using namespace std;

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

int main() {
    int N;
    cin >> N;
    long long sum = 1;
    for (int i = 1; i <= N; i++) {
        sum *= i;
        sum %= 1000000007;
    }
    cout << sum << endl;
}

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

using namespace std;

typedef long long ll;


int main(void)
{
    int n,a,b;

    cin >> n >> a  >> b;

    cout << min(n*a,b)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define num 1000000007
#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
ll A[300005],mx[300005],mn[300005],cur[300005];
void assign(ll n)
{
	REP(i,1,n)
	{
		A[i]=mx[i]=mn[i]=cur[i]=i;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,W;
	ll a[100005],b[100005];
	cin>>n>>W;
	ll dp[n+1][W+1];
	REP(i,0,n)
	{
		cin>>a[i]>>b[i];
	}
	REP(i,0,n+1)
	{
		REP(j,0,W+1)
		{
			if(i==0 || j==0)
			{
				//cout<<"0 ";
				dp[i][j]=0;
			}
			else if(a[i-1]<=j)
			{
				//cout<<"1 ";
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1]]+b[i-1]);
			}
			else
			{
				//cout<<"2 ";
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	//REP(i,0,n+1){REP(j,0,W+1){cout<<dp[i][j]<<" ";}cout<<endl;}
	cout<<dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 79232
/**
 *   author  : The San Cao (caothesan@gmail.com)
 *   created : 2020.02.08 10:28:09 +07
 */

#include <iostream>

using namespace std;

int main() {
  int w, h, n; cin >> w >> h >> n;
  if (w < h) swap(w, h);
  cout << ((n - 1) / w) + 1 << "\n";
  return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var s string
  fmt.Scan(&s)
  res := make(map[rune]int)
  for _, c := range s {
    res[c]++
  }
  ans := "Yes"
  for _, v := range res {
    if v != 2 {
      ans = "No"
      break
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include<stdio.h>
//素数判定
int isPrime(int x){
    int i;
    if(x < 2) return 0;
    else if(x == 2) return 1;
    if( x % 2 == 0) return 0;
    for(i=3; i*i<=x; i+=2){
        if(x % i == 0) return 0;
    }
    return 1;
}

int main(){
    int n, x, i;
    int cnt = 0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &x);
        if(isPrime(x)) cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 2668
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int a, b, c;

signed main()
{
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;


    return 0;
}
/*


*/




Measured memory_bytes: 256
import copy

s = input()

c_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

min_loop = len(s)
for c in c_list:
    if s.count(c) == 0:
        continue
    s_ = copy.copy(s)
    new_s = copy.copy(s)
    loop = 0
    while new_s.count(c) != len(new_s):
        len_s_ = len(s_)
        new_s = ""
        for i in range(len_s_ - 1):
            if s_[i] == c or s_[i+1] == c:
                new_s += c
            else:
                new_s += s_[i]
        loop += 1
        s_ = copy.copy(new_s)
    if loop < min_loop:
        min_loop = loop

print(min_loop)



Measured memory_bytes: 3444
from collections import Counter
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
index,cnt=zip(*Counter(a).most_common())
ans=0
for i in range(len(index)):
    if cnt[i]%2==1:
        ans+=1
print(ans)
#print(index,cnt)

Measured memory_bytes: 22392
using System;
using System.Collections.Generic;
namespace std
{
    class Test {
        static void Main(string[] args) {
           
            List<int> ary_num = new List<int>();
              
                var n = int.Parse(Console.ReadLine());
                 int [] input = new int[n]; 
                for (int i = 0; i < n; i++) {
                    input[i] = int.Parse(Console.ReadLine());
                }
               int min = input[0];
               int max = input[1] - input[0];
                for (int j = 1; j < n; j++) {
                    if (max < input[j] -min) {
                        max = input[j] - min;
                    }  
                    if (min > input[j]) {
                        min = input[j];
                    }
                   
                }
                Console.WriteLine(max);
                
      
        }
    }
}



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

using namespace std;

#define ll long long

/* ax+by=gcd(a,b)を満たす(x,y)を格納し、gcd(a,b)を返す. */
ll extgcd(ll a, ll b, ll& x, ll& y){
    if (b > a) return extgcd(b, a, y, x);
    if (b == 0){
        x = 1; y = 0;
        return a;
    }
    int g = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return g;
}

signed main(){
    ll a, b; cin >> a >> b;
    ll x, y;
    extgcd(a, b, x, y);
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll r;
    cin >> r;
    cout << r*r;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char x[10];

  while(scanf("%s",x) != EOF){
    if( (x[0]=='o' && x[0]==x[1] && x[1]==x[2])
    ||  (x[3]=='o' && x[3]==x[4] && x[4]==x[5])
    ||  (x[6]=='o' && x[6]==x[7] && x[7]==x[8])
    ||  (x[0]=='o' && x[0]==x[3] && x[3]==x[6])
    ||  (x[1]=='o' && x[1]==x[4] && x[4]==x[7])
    ||  (x[2]=='o' && x[2]==x[5] && x[5]==x[8])
    ||  (x[0]=='o' && x[0]==x[4] && x[4]==x[8])
    ||  (x[2]=='o' && x[2]==x[4] && x[4]==x[6]) ){
      printf("o\n");
    }
    else if( (x[0]=='x' && x[0]==x[1] && x[1]==x[2])
    ||  (x[3]=='x' && x[3]==x[4] && x[4]==x[5])
    ||  (x[6]=='x' && x[6]==x[7] && x[7]==x[8])
    ||  (x[0]=='x' && x[0]==x[3] && x[3]==x[6])
    ||  (x[1]=='x' && x[1]==x[4] && x[4]==x[7])
    ||  (x[2]=='x' && x[2]==x[5] && x[5]==x[8])
    ||  (x[0]=='x' && x[0]==x[4] && x[4]==x[8])
    ||  (x[2]=='x' && x[2]==x[4] && x[4]==x[6]) ){
      printf("x\n");
    }
    else{
      printf("d\n");
    }
  }

  return 0;
}

Measured memory_bytes: 0
A = list(map(int, input().split()))
a = A[0]
b = A[1]
c = A[2]
if (a == b) and (a == c) and (b == c):
  print(1)
elif (a == b) or (a == c) or (b == c):
  print(2)
else:
  print(3)

Measured memory_bytes: 3060
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

ll C[51][51];

void comb_table(int N) {
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i) {
        C[i][j] = 1LL;
      } else {
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
      }
    }
  }
}

int main()
{
  
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  
  comb_table(n);
  
  sort(vec.begin(), vec.end(), greater<>());
  double ave = 0.0;
  for (int i = 0; i < a; i++) {
    ave += vec[i];
  }
  ave /= a;
  
  cout.precision(20);
  cout << fixed << ave << endl;
  
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (vec[i] == vec[a - 1]) {
      cnt++;
    }
  }
  
  ll res = 0;
  if (vec[0] == vec[a - 1]) {
    for (int i = a; i <= b; i++) {
      res += C[cnt][i];
    }
  } else {
    int pos = 0;
    for (int i = 0; i < a; i++) {
      if (vec[i] == vec[a - 1]) {
        pos++;
      }
    }
    res += C[cnt][pos];
  }
  cout << res << endl;
  return 0;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}

		public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var S = retreiveStringArray()[0].Select(x =>x).ToArray();

			var chars = Enumerable.Range('a', 26).Select(x =>(char)x);
			var dic = new Dictionary<char, int>();
			foreach (var ch in chars) {
				dic.Add(ch, 1);
			}

			for (int i = 0; i < N; i++) {
				dic[S[i]] += 1;
			}

			//答えの出力
			long ans = 1;

			foreach (var ch in chars) {
				ans *= dic[ch];
				ans %= _mod;
			}
			Console.WriteLine(ans-1);

		}

		private static long _mod = 1000000000 + 7;
		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 19492
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
long long n,m;

int main()
{
    IO;
    int n;
    cin>>n;
    int res=0;
    for(int i=1;i<n;i++)
    {
        res+=(n-1)/i;
    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3588
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            n = In[0];
            a = In[1];
            b = In[2];
            c = In[3];
            L = new int[n];
            for(int i=0; i < n; i++)
            {
                L[i] = int.Parse(Console.ReadLine());
            }
            DFS(0, 0, 0, 0, 0);
            Console.WriteLine(min);
        }
        static public int a, b, c, n;
        static public int min=1001001001;
        static public int[] L;
        static public void DFS(int x,int y,int z,int idx,int cnt)
        {
            if (idx == n)
            {
                Chk(x, y, z,cnt);
                return;
            }
            idx++;
            DFS(x, y, z, idx,cnt);
            cnt++;
            DFS(x + L[idx-1], y, z, idx, cnt);
            DFS(x, y + L[idx-1], z, idx, cnt);
            DFS(x, y, z + L[idx-1], idx, cnt);
        }
        static public void Chk(int x, int y, int z,int cnt)
        {
            if (cnt < 3) return;
            if (x == 0 || y == 0 || z == 0) return;
            cnt -= 3;
            int sum = 10*cnt + (int)Math.Abs(a - x) + (int)Math.Abs(b - y) + (int)Math.Abs(c - z);
            min = (int)Math.Min(min, sum);
        }
    }
}


Measured memory_bytes: 27904
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll a[4]= {1,2,4,8};
	ll c[4];
	for(int i=0;i<4;i++)
		cin>>c[i];
	for(int i=0;i<4;i++)
	{
		for(int j=i+1;j<4;j++)
		{
			if(c[i]*a[j]>c[j]*a[i])
			{
				swap(a[i],a[j]);
				swap(c[i],c[j]);
			}	
		}
	}
	
	ll N;
	cin>>N;
	N*=4;
	ll ans=0;
	for(int i=0;i<4;i++)
	{
		ans+=N/a[i]*c[i];
		N%=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <string>
using namespace std;
int main(){
string b;
cin >> b;
string A = "A";
string T = "T";
string G = "G";
string C = "C";
if(b == A){
    cout << T;
}
if(b == T){
    cout << A;
}
if(b == G){
    cout << C;
}
if(b == C){
    cout << G;
}
}



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

int main(){
  int N;
  cin >> N;
  vector<long long> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  long long num = 1;
  for(int i = 0; i < N; i++){
    if(vec.at(i) == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  long long comp = pow(10,18);
  for(int i = 0; i < N; i++){
    if(vec.at(i) > comp/num){
      num = -1;
      break;
    }
    num = num * vec.at(i);
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 4048
#include<stdio.h>
#include<stdlib.h>
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
  
Node root;
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;  
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else y->right = z;
}
  
  
void inorder(Node u){
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
  
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!= NIL){
    preorder(u->left);
  }
  if(u->right!= NIL){
    preorder(u->right);
  }
    
}
  
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
 
alias P = Tuple!(int, "x", int, "y");
 
bool comp(P a, P b)
{
	if (a.y >= b.x) {
		return false;
	}
	if (a.x >= b.y) {
		return false;
	}
	return true;
}
 
void main()
{
	int n = readln.chomp.to!int;
	P[] reds;
	foreach (i; 0..n) {
		auto ab = readln.chomp.split.map!(to!int);
		reds ~= P(ab.back, ab.front);
	}
	P[] blues;
	foreach (i; 0..n) {
		auto ab = readln.chomp.split.map!(to!int);
		blues ~= P(ab.front, ab.back);
	}
	reds = std.algorithm.sort(reds).retro.array;
	blues = std.algorithm.sort(blues).array;
	int ans = 0;
	bool[ulong] done;
	foreach (b; blues) {
		foreach (i, r; reds) {
			if (!comp(r, b)) {
				continue;
			}
			if (i in done) {
				continue;
			}
			done[i] = true;
			++ans;
			break;
		}
	}
	ans.writeln;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
    long long num, ticket;
    cin >> num >> ticket;

    priority_queue<int> item_queue;
    for(int i = 0; i < num; ++i) {
        int item;
        cin >> item;
        item_queue.push(item);
    }

    for(int i = 0; i < ticket; ++i) {
        int item = item_queue.top();
        item_queue.pop();
        item_queue.push(item / 2);
    }

    long long sum = 0;
    while(!item_queue.empty()) {
        sum += item_queue.top();
        item_queue.pop();
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, m, i, j, k, a, b, s, t, x, y, id, d;
	cin >> n >> m >> s >> t;
	vector<vector<pair<long long, long long>>> adjs(n + 1), adjt(n + 1);
	for (i = 0; i < m; i++) {
		cin >> a >> b >> x >> y;
		adjs[a].push_back({ b, x });
		adjs[b].push_back({ a, x });
		adjt[a].push_back({ b, y });
		adjt[b].push_back({ a, y });
	}

	vector<long long> ds(n + 1, 1LL << 60), dt(n + 1, 1LL << 60);
	queue<pair<long long, long long>> q;		// -dist, id

	ds[s] = 0;
	q.push({ 0, s });
	while (!q.empty()) {
		d = -q.front().first;
		id = q.front().second;
		q.pop();

		if (ds[id] != d) continue;

		for (auto p : adjs[id]) {
			if (d + p.second < ds[p.first]) {
				ds[p.first] = d + p.second;
				q.push({ -ds[p.first], p.first });
			}
		}
	}

	dt[t] = 0;
	q.push({ 0, t });
	while (!q.empty()) {
		d = -q.front().first;
		id = q.front().second;
		q.pop();

		if (dt[id] != d) continue;

		for (auto p : adjt[id]) {
			if (d + p.second < dt[p.first]) {
				dt[p.first] = d + p.second;
				q.push({ -dt[p.first], p.first });
			}
		}
	}

	vector<long long> ans(n + 1, 1LL << 60);
	for (i = n - 1; i >= 0; i--) {
		ans[i] = min(ans[i + 1], ds[i + 1] + dt[i + 1]);
	}

	for (i = 0; i < n; i++) cout << 1000000000000000LL - ans[i] << "\n";


	return 0;
}


Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
int main(){
    int D;
    cin>>D;
    if(D==25)cout<<"Christmas"<<endl;
    if(D==24)cout<<"Christmas Eve"<<endl;
    if(D==23)cout<<"Christmas Eve Eve"<<endl;
    if(D==22)cout<<"Christmas Eve Eve Eve"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	a--;b--;c--;d--;
	string s;
	cin>>s;
	bool x=false,y=false;
	for(int i=a+1;i<max(c,d)-1;i++)
		if(s[i]=='#' and s[i+1]=='#')x=true;
	for(int i=b-1;i<d;i++)
		if(s[i]=='.' and s[i+1]=='.' and s[i+2]=='.')y=true;
	if(!x and(c<d or y))cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    string ans = "Yes";
    
    while(true){
        C -= B;
        if(C<=0) break;
        A -= D;
        if(A<=0){
            ans = "No";
            break;
        }
    }
    cout << ans << ln;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

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

	if ((!((n - 3) % 10))) cout << "bon";
	else if (!(n % 10)) cout << "pon";
	else if (!((n - 1) % 10)) cout << "pon";
	else if (!((n - 6) % 10)) cout << "pon";
	else if (!((n - 8) % 10)) cout << "pon";
	else if (!((n - 2) % 10)) cout << "hon";
	else if (!((n - 4) % 10)) cout << "hon";
	else if (!((n - 5) % 10)) cout << "hon";
	else if (!((n - 7) % 10)) cout << "hon";
	else if (!((n - 9) % 10)) cout << "hon";

	return 0;
}

Measured memory_bytes: 3636
n = int(input())
ta = []
for i in range(n):
    t,a = map(int,input().split())
    ta.append([t,a])
count = ta[0][0] + ta[0][1]
t = ta[0][0]
a = ta[0][1]
for i in range(1,n):
    if ta[i][0] == ta[i][1]:
        count += max(t,a) - min(t,a)
        t = max(t,a)
        a = max(t,a)
    elif ta[i][0] > ta[i][1]:
        if a % ta[i][1] != 0:
            count += ta[i][1] - (a % ta[i][1])
            a += ta[i][1] - (a % ta[i][1])
        if (a//ta[i][1]) * ta[i][0] >= t:
            count += (a//ta[i][1]) * ta[i][0] - t
            t = (a//ta[i][1]) * ta[i][0]
        else:
            if t % ta[i][0] != 0:
                count += ta[i][0] - (t % ta[i][0])
                t += ta[i][0] - (t % ta[i][0])
            count += (t//ta[i][0]) * ta[i][1] - a
            a = (t//ta[i][0]) * ta[i][1]
    else:
        if t % ta[i][0] != 0:
            count += ta[i][0] - (t % ta[i][0])
            t += ta[i][0] - (t % ta[i][0])
        if (t//ta[i][0]) * ta[i][1] >= a:
            count += (t//ta[i][0]) * ta[i][1] - a
            a = (t//ta[i][0]) * ta[i][1]
        else:
            if a % ta[i][1] != 0:
                count += ta[i][1] - (a % ta[i][1])
                a += ta[i][1] - (a % ta[i][1])
            count += (a//ta[i][1]) * ta[i][0] - t
            t = (a//ta[i][1]) * ta[i][0]
print(count)

Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    string s;
    cin >> s;
    if (s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstdio>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 200007;
const int M = 15005;
const int offset = 7500;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double eps = 1e-20;
LL n,m;
LL ans[105];
int main()
{
    while (~scanf("%lld",&n))
    {
        LL tmp = n/50;
        LL tm = n%50;
        for (int i=0;i<50;i++)
            ans[i] = i + tmp ;
        for (int i=49; i>=0 && tm>0;i--)
        {
            ans[i]++;
            tm--;
            // cout<<i<<" "<<ans[i]<<endl;
        }
        printf("50\n");
        for (int i=0;i<50;i++)
        {
            printf("%lld", ans[i]);
            if (i<49)
                printf(" ");
            else
                printf("\n");
        }
        
    }
    return 0;
}

/*


*/

Measured memory_bytes: 256
import java.util.Scanner;
  
public class Main{
  public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  if (a <= b*c){
    System.out.println("Yes");
  }else{
    System.out.println("No");
  } 
 }
}

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

int main(){
    string S, T;
    int n;
    cin >> S >> T;
    
    if(S[0]==T[0])
    n++;
    if(S[1]==T[1])
    n++;
    if(S[2]==T[2])
    n++;
    
    cout << n << endl;
}

Measured memory_bytes: 256
mod = 10**9+7
n = int(input())


def check(last4):
    if "AGC" in last4:
        return False
    for i in range(3):
        l = list(last4)
        l[i],l[i+1] = l[i+1], l[i]
        if "AGC" in "".join(l):
            return False
    return True

memo = [{} for i in range(n)]
# 再帰
def dfs(depth=0, last3="TTT"):
    if depth == n:
        # 遷移できる前提だから↓は必ず1になるはず
        #return int(last3 in ["AGC", "ACG", "GAC"])
        return 1
    if last3 in memo[depth]:
        return memo[depth][last3]

    res = 0
    for c in "ACGT":
        if check(last3+c):
            res += dfs(depth+1, last3[1:]+c)
            res %= mod
    memo[depth][last3] = res
    return res

print(dfs())

Measured memory_bytes: 3884
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

a.sort()

from bisect import bisect_left
from bisect import bisect_right

pos = n - bisect_left(a, 1)
neg = bisect_right(a, -1)


ans_exec = []

if pos>=neg:
    aa = a[max(0,neg-1):n-neg+1]
    for i in range(neg-1):
        ans_exec.append((a[-1-i], a[i]))
        aa.append(a[-1-i] - a[i])
    aa.sort()
    tmp = aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans_exec.append((aa[-1], tmp))
    ans = aa[-1] - tmp

elif pos<=neg:
    aa = a[max(0,pos-1):n-pos+1]
    for i in range(pos-1):
        ans_exec.append((a[i], a[-1-i]))
        aa.append(a[i] - a[-1-i])
    aa.sort()
    tmp = aa[-1]
    ans_exec.append((aa[-1], aa[0]))
    tmp = aa[-1]-aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans = tmp


print(ans)
for a,b in ans_exec:
    print(a,b)


Measured memory_bytes: 19988
n =int(input())
A=[]
for I in range(n):
  moji=list(input())
  moji.sort()
  moji=''.join(moji)
  A.append(moji)
A.sort()
N=0
SUM=0
i=0
while True:
  if i==n-1:
    SUM=SUM+int(0.5*N*(N+1))
    break
  a=A[i]
  for s in range(i+1,n,1):
    b=A[s]
    if a==b:
      N+=1
      i+=1
    else:
      SUM=SUM+int(0.5*N*(N+1))
      N=0
      i=s
      break
print(SUM)

Measured memory_bytes: 57688
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> P;

const int N = 10;
const double INF = 1e77;
const double EPS = 1e-8;

int n, m, ans[N];
P dogs[N];
double dv[N];

void init(){
  fill(ans, ans+N, 0);
}

double dot(P a, P b){
  return real(conj(a) * b);
}

double f2(P a){
  return a.real() * a.real() + a.imag() * a.imag();
}

double f1(P a){
  return sqrt(f2(a));
}

void calc(P fp, P fv){
  double time[N];
  for(int i=0;i<n;i++){
    double a = norm(fv) - dv[i] * dv[i];
    double b = -dot(fv, dogs[i] - fp);
    double c = norm(dogs[i] - fp);
    //cout << a << ' ' << b << " " << c << endl;
    if(abs(a) > EPS){
      time[i] = INF;
      if(b * b > a * c){
        double d1 = (-b + sqrt(b * b - a * c)) / a;
        double d2 = (-b - sqrt(b * b - a * c)) / a;
        //cout << d1 << ' ' << d2 << endl;
        if(d1 > -EPS) time[i] = min(time[i], d1);
        if(d2 > -EPS) time[i] = min(time[i], d2);
      }
    }else if(abs(b) > EPS){
      //cout << "b" << endl;
    }else{
      //cout << "c" << endl;
    }
  }
  int id = min_element(time, time+n) - time;
  /*cout << n << endl;
  for(int i=0;i<n;i++){
    cout << time[i] << endl;
    }*/
  if(time[id] > EPS){
    for(int i=0;i<n;i++){
      if(time[i] < INF / 2){
        P v = (fp + fv * time[i]) - dogs[i];
        v /= f1(v);
        dogs[i] += v * dv[i] * time[id];
      }
    }
  }
  ans[id]++;
}

main(){
  while(cin >> n >> m && (n|m)){
    init();
    for(int i=0;i<n;i++){
      cin >> dogs[i].real() >> dogs[i].imag() >> dv[i];
    }
    for(int i=0;i<m;i++){
      P fp, fv;
      cin >> fp.real() >> fp.imag() >> fv.real() >> fv.imag();
      calc(fp, fv);
    }
    for(int i=0;i<n;i++){
      cout << ans[i] << (i+1<n ? " " : "");
    }
    cout << endl;
  }
}

Measured memory_bytes: 1260
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

struct bill{int n, x, y;};

double len[1001][1001], dist[1001];
int used[1001], prev[1001];
const double INF = 10000000;

std::vector<int> dijkstra(int s, int e){
	std::fill(dist, dist+1001, INF);
	std::fill(used, used+1001, 0);
	std::fill(prev, prev+1001, 0);

	dist[s] = 0;
	while(1){
		int v = -1;
		for(int u=1;u<1001;u++){
			if(!used[u] && (v==-1 || dist[u]<dist[v]))v=u;
		}
		if(v == -1)break;
		used[v] = 1;
		for(int u=1;u<1001;u++){
			if(dist[u] > dist[v]+len[v][u])
				dist[u] = dist[v]+len[v][u], prev[u] = v;
		}
	}
	std::vector<int> res;
	if(dist[e] == INF)res.push_back(-1);
	else{
		res.push_back(e);
		int v = e;
		while(v != s){
			v = prev[v];
			res.push_back(v);
		}
		std::reverse(res.begin(), res.end());
		return res;
	}
}


int main(){
	int n;
	while(std::cin >> n, n){
		for(int i=1;i<1001;i++)
		 	for(int j=1;j<1001;j++)
		 		len[i][j] = INF;

		std::vector<bill> bs;
		for(int i=n;i;i--){
			bill b;
			std::cin >> b.n >> b.x >> b.y;
			bs.push_back(b);
		}

		for(int i=0;i<bs.size()-1;i++){
			for(int j=i+1;j<bs.size();j++){
				double x = bs[i].x-bs[j].x, y = bs[i].y-bs[j].y, dist = sqrt(x*x+y*y);
				if(dist <= 50){
					len[bs[i].n][bs[j].n] = dist;
					len[bs[j].n][bs[i].n] = dist;
				}
			}
		}

		int m;
		std::cin >> m;
		for(;m;m--){
			int start, end;
			std::cin >> start >> end;
			std::vector<int> res = dijkstra(start, end);
			if(res[0] == -1)std::cout << "NA\n";
			else{
				for(int i=0;i<res.size();i++){
					std::cout << res[i] << (i+1-res.size()?" ":"\n");
				}
			}
		}
	}
}

Measured memory_bytes: 8756
n = int(input())
bt,bx,by=0,0,0
ans=True
for i in range(n):
    t, x, y = map(int, input().split())
    dt=t-bt
    l=abs(x-bx)+abs(y-by)
    if dt<l:
        ans = False
    if (dt-l)%2:ans=False

    bt,bx,by=t,x,y
print('Yes' if ans else 'No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	(((a>=1)&&(a<=100))&&((b>=1)&&(b<=100)));
	printf("%d %d\n",a*b,2*a+2*b);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int a,b; cin >> a >> b;
    cout << a*b << endl;
return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  pair<pair<string,int>, int> p[n];
  rep(i, 0, n) {
    int s;
    cin >> p[i].first.first >> s;
    p[i].first.second = -s;
    p[i].second = i + 1;
  }
  sort(p, p + n);
  rep(i, 0, n) { cout << p[i].second << endl; }
  return 0;
}

Measured memory_bytes: 3620
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, m;
	string s;

	cin >> s;

	string seis = { s[0],s[1],s[2],s[3] };
	string mons = { s[5],s[6] };
	string days = { s[8],s[9] };

	int sei = stoi(seis);
	int mon = stoi(mons);
	int day = stoi(days);

	if (sei > 2019) {
		cout << "TBD" << endl;
	}
	else if (sei == 2019 && mon > 4) {
		cout << "TBD" << endl;
	}
	else if (sei == 2019 && mon == 4 && day > 30) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}




	return 0;
}

Measured memory_bytes: 256
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     string s;
     vector<char> v;
     cin>>s;
     int len = s.length();
     int queries;cin>>queries;
     int j=0;
     int x = 0;
     while(queries--)
     {
         int type;cin>>type;
         if(type==1)//reverse
         {
             if(j==0)
             {
                 j = len-1;
             }
             else
             {
                 j = 0;
             }
             x = !x;             
         }
         else
         {
             int type2;cin>>type2;
             char c;cin>>c;
             if(type2 == 1)//start me add
             {
                 if(x==1)
                 {
                     s += c;
                 }
                 else
                 {
                     v.pb(c);
                 }
                 
             }
             else//end m add
             {
                 if(x==1)
                 {
                     v.pb(c);
                 }
                 else
                 {
                     s += c;
                 }
                 
             }
             
         }         
     }
     if(x==1)
     {
         reverse(s.begin(),s.end());
         for(auto it:v)
         {
             s += it;
         }
         cout<<s<<endl;
     }
     else
     {
         string new_s="";
         for(auto it:v)
         {
             new_s += it;
         }
         reverse(new_s.begin(),new_s.end());
         new_s += s;
         cout<<new_s<<endl;
     }
     //cout<<s<<endl;
     
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 1320
'use strict';

const X=require('fs').readFileSync('/dev/stdin','utf-8')-0;
const pow=Math.pow

function main(){
for(let A=150;A;A--)
    for(let B=A;A+B;B--)
      if(pow(A,5)-pow(B,5)===X){
        console.log(A+' '+B);
        return;
      }
}

main();

Measured memory_bytes: 33456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
			String S=sc.next();
			String T=sc.next();
			
			StringBuilder buff = new StringBuilder();
			buff.append(S);
			buff.append(T);
			
			System.out.println(T+S);
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
  int N; cin >> N;
  vector<pair<int, int>> sect(N);
  for (int i = 0; i < N; ++i){
    int X, L; cin >> X >> L;
    sect[i] = {X - L, X + L};
  }

  sort(
    sect.begin(), sect.end(),
    [](auto p, auto q){
      return p.second < q.second;
    }
  );

  int nx = -2000000000;
  int res = 0;
  for (auto s : sect){
    if (s.first >= nx){ // 選択可能
      nx = s.second;
      ++res;
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3996
import itertools
import functools
import math
from collections import Counter
from itertools import combinations


S=input()

N=int(len(S))

A1=S[:N//2]
A2=S[((N+3)//2)-1:]


chk = 0

for i in range(N-1//2):
    if S[i]!=S[N-1-i]:
        chk = 1
        print('No')
        exit()

for i in range((N-1)//2):
    if A1[i] != A1[((N-1)//2) - (N%2) - i]:
        chk = 1
        break
    if A2[i] != A2[((N-1)//2) - (N%2) - i]:
        chk = 1
        break

if chk == 0:
    print('Yes')
else:
    print('No')


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


using namespace std;

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

	if(A%3==0 || B%3==0 || (A+B)%3==0)cout<<"Possible\n";
	else cout<<"Impossible\n";
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[4];
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[1]==5&&a[2]==5&&a[3]==7)
    	return cout<<"YES",0;
    return cout<<"NO",0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int A;
   int ans = 100000000;
   for(int i=0; i<N; ++i){
      std::cin >> A;
      int n = 0;
      while(A%2==0){
	 A /= 2;
	 ++n;
      }
      ans = std::min(n,ans);
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
   // ?¨??????\???????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for (int i = 0; i < values.length; i++) {
        	values[i] = i + 1;
        }
        for (int i = 0; i < n; i++) {
        	String str = sc.next();
            String[] ab = str.split(",");
        	int a = Integer.parseInt(ab[0]) - 1;
        	int b = Integer.parseInt(ab[1]) - 1; 
        	// a??¨b????????£???values??????????????????
        	int tmp =values[a];
        	values[a] = values[b];
        	values[b] = tmp;
        }
        for(int xxx=0;xxx<w;xxx++){
            System.out.println(values[xxx]);
        }
     // values??????????????????
	} 
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int ans = 1;
  for(int i=0;i<N;i++){
    if(ans<K){
      ans*=2;
    }
    else{
      ans+=K;
    }
  }
  cout<<ans<<endl;
  return 0;
}
      

Measured memory_bytes: 256
"use strict"

function main(input) {
  input = input.split(/\n/).map(v => ~~v)

  const n = input[0]
  const k = input[1]
  let ans = 1
  for (let i = 0; i < n; i++) {
    if (ans > k) {
      ans += k
    } else {
      ans *= 2
    }
    //
  }
  console.log(ans)
  //
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    int x,y,z,k;cin>>x>>y>>z>>k;
    vi a(x),b(y),c(z);
    vi v;
    rep(i,x)cin>>a[i];
    rep(i,y)cin>>b[i];
    rep(i,z)cin>>c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));
    rep(i,x){
        rep(j,y){
            ll sum=a[x-i-1]+b[y-j-1];
            rep(l,z){
                if((i+1)*(j+1)*(l+1)>k)break;
                v.pb(sum+c[z-l-1]);
            }
        }
    }
    sort(all(v));
  reverse(all(v));
  rep(i,k)cout<<v[i]<<endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> T(N + 1, 0), X(N + 1, 0), Y(N + 1, 0);
  for (int i = 1; i <= N; i++)
    cin >> T[i] >> X[i] >> Y[i];
  for (int i = 0; i < N; i++) {
    int t = T[i + 1] - T[i];
    int x = abs(X[i + 1] - X[i]);
    int y = abs(Y[i + 1] - Y[i]);
    if (t < x + y || (t - (x + y)) % 2 != 0) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}


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

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

    bool ok = a + b + 2 * sqrtl(a * b) < c;
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
"""
考察:





"""

H,W = map(int,input().split())

s = []

for i in range(H):

    S = list(input())
    s.append(S)

dis = [[float("inf")] * W for i in range(H)]

if s[0][0] == "#":
    dis[0][0] = 1
else:
    dis[0][0] = 0

for i in range(H):

    for j in range(W):

        if i != H-1:

            if s[i][j] == "." and s[i+1][j] == "#":

                dis[i+1][j] = min(dis[i][j] + 1,dis[i+1][j])

            else:
                dis[i+1][j] = min(dis[i][j],dis[i+1][j])

        if j != W-1:
            if s[i][j] == "." and s[i][j+1] == "#":

                dis[i][j+1] = min(dis[i][j] + 1,dis[i][j+1])

            else:
                dis[i][j+1] = min(dis[i][j],dis[i][j+1])

print (dis[-1][-1])

Measured memory_bytes: 3188