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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		String s = "";
		if(n == 25) {
			s = "Christmas";
		}else if(n == 24) {
			s = "Christmas Eve";
		}else if(n == 23) {
			s = "Christmas Eve Eve";
		}else if(n == 22) {
			s = "Christmas Eve Eve Eve";
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 22608
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, L, q;
	cin >> N;
	VI X(N);
	REP(i, N)cin >> X[i];
	cin >> L >> q;


	int dp[30][100010];
	int day[30][100010];
	//jから2のi乗個進んだ距離
	//jから2のi乗日で進める個数

	REP(i, 30)REP(j, 100010)dp[i][j] = day[i][j] = INF * 10;


	int k = 0, s = 0, g = 0;

	while (k < N - 1) {
		//cout << [g + 1] << " " << sum[s] << endl;
		if (g != N - 1) {
			while (X[g + 1] - X[s] <= L) {
				g++;
				if (g == N - 1)break;
			}
		}
		day[0][k] = g - s;
		//cout << day[0][k] << " " << k << " " << g << " " << s << endl;
		k++;
		s++;
	}
	
	FOR(i, 1, 30) {
		REP(j, N - 1) {
		
			if (j + day[i-1][j] >= N -1)continue;
			//cout << i << " " << j << " " << day[i - 1][j] << " " << day[i - 1][j + day[i - 1][j]] << endl;
			
			//cout << i << " " << j <<" "<< day[i][j] << endl;
			day[i][j] = day[i - 1][j] + day[i - 1][j + day[i - 1][j]];
			
		}
	}
	/*
	REP(i, 30) {
		REP(j, N) {
			if (day[i][j] != INF * 10) {
				//cout << day[i][j] << " ";
				//cout << i << " " << j << " " << day[i][j] << endl;
			}
		}
		//cout << endl;
	}
	*/


	while (q--) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (b < a)swap(a,b);
		int ans = 0;
		int now = a;
		
		do {
			//cout << ans <<" "<<now<< endl;
			//cout << q << " " << ans << " " << dist << endl;
		
			bool F = true;

			for (int i = 25; i >= 0; i--) {
				if (day[i][now] + now <= b) {
					F = false;
					
					now += day[i][now];
					ans += (1LL << i);
					if (now == b) {
						F = true;
						break;
					}
				}
			}

			if (F) {
				if (now != b)ans++;
				cout << ans << endl;
				break;
			}
			else continue;

		} while (1);
	}
	return 0;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int judge = A + B - C - D;
  string result;
  if ( judge > 0 ) {
    result = "Left";
  }
  else if ( judge == 0 ) {
    result = "Balanced";
  }
  else {
    result = "Right";
  }
  cout << result << endl;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve xs

solve :: U.Vector Int -> Int
solve xs = sum.map (f.length).group.sort.U.toList $ U.scanl (+) 0 xs
  where
    f n = n * (n - 1) `div` 2



Measured memory_bytes: 38268
#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

H,W = II()
A = [list(map(str, input())) for _ in range(H)]
for i in range(H):
  A[i].append('?')
A.append(['?']*(W+1))

i=0;j=0
A[i][j]='.'
while 1:
  if i==H-1 and j==W-1:
    break
  if A[i+1][j]=='#':
    A[i+1][j]='.'
    i +=1
    continue
  if A[i][j+1]=='#':
    A[i][j+1]='.'
    j +=1
    continue
  print('Impossible')
  exit()

ans = 'Possible'
for i in range(H):
  for j in range(W):
    if A[i][j]=='#':
      ans = 'Impossible'
print(ans)

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

using namespace std;

int main() {
    int N, cnt = 0;
    string S;
    cin >> N;
    cin >> S;
    char C1, C2, C3;

    for (int i = 0; i < S.size() - 2; ++i) {
        C1 = S[i];
        C2 = S[i + 1];
        C3 = S[i + 2];
        if (C1 == 'A' && C2 == 'B' && C3 == 'C')cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3596
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#include <map>
#define ll long long 
#define PI 3.14159265358979323846
#define INF 10000000000
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N;
	cin >> N;
	if (N >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
// Digit Sums

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int DigitSums(int n){
	if (n/10 == 0)
		return n;

	return n%10 + DigitSums(n/10);
}

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

	int SN;
	SN = DigitSums(N);

	if (N % SN)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}


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

// int main(){
//     int n, m;
//     cin >> n >> m;
//     vector<vector<int>> dp(m+50,vector<int>(n+100,INF));
//     rep(i,m+1)dp[i][0] = 0;
//     vector<int> c(m+1);
//     rrep(i,m)cin >> c[i];
//     rrep(i,m){
//         rrep(j,n){
//             if(j-c[i]<0)dp[i][j] = dp[i-1][j];
//             else dp[i][j] = min(dp[i][j-c[i]]+1, dp[i-1][j]);
//         }
//     }
//     cout << dp[m][n] << endl;
//     return 0;
// }

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> dp(n+100);
    rep(i,dp.size())dp[i]=INF;
    vector<int> c(m+1);
    rrep(i,m)cin >> c[i];
    dp[0]=0;
    rrep(j,n){
        for(int i = 1; i<=m; ++i){
            if(j-c[i]<0)continue;
            dp[j] = min(dp[j],dp[j-c[i]]+1);
        }
    }
    
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define all(c) begin(c),end(c)

typedef vector<string> vs;

template<typename T>
void update_max(T& a,const T& b)
{
	a=max(a,b);
}

void dfs(vs& grid,int i,int j)
{
	int h=grid.size(),w=grid[0].size();
	if(i<0 || h<=i || j<0 || w<=j || grid[i][j]=='.')
		return;
	grid[i][j]='.';
	rep(k,4)
		dfs(grid,i+"\xff\x1\0\0"[k],j+"\0\0\xff\x1"[k]);
}

bool can_connect(const vs& _grid)
{
	vs grid=_grid;
	int cnt=0;
	rep(i,grid.size()) rep(j,grid[i].size())
		if(grid[i][j]=='#'){
			dfs(grid,i,j);
			cnt++;
		}
	return cnt<=1;
}

bool can_place(const string& key,int i,char c)
{
	if(c=='#')
		return !(i>0 && isdigit(key[i]) && key[i]==key[i-1]);
	else{
		if(key[i]=='.' || (i>0 && key[i-1]=='.'))
			return false;
		if(isdigit(key[i]) && count(all(key),key[i])==1)
			return false;
		return true;
	}
}

string adjust(string s)
{
	vector<int> m(10,-1);
	int k=0;
	rep(i,s.size())
		if(isdigit(s[i]) && m[s[i]-'0']==-1)
			m[s[i]-'0']=k++;
	rep(i,s.size())
		if(isdigit(s[i]))
			s[i]=m[s[i]-'0']+'0';
	return s;
}

string place(const string& key,int i,char c)
{
	string res=key;
	if(c=='#'){
		if(isdigit(key[i]) && i>0 && isdigit(key[i-1]))
			replace(all(res),max(key[i-1],key[i]),min(key[i-1],key[i]));
		else if(isdigit(key[i]))
			;
		else if(i>0 && isdigit(key[i-1]))
			res[i]=key[i-1];
		else
			res[i]=max<char>(*max_element(all(key))+1,'0');
	}
	else
		res[i]='.';
	return adjust(res);
}

int solve(vs& grid)
{
	if(!can_connect(grid))
		return -1;
	
	int h=grid.size(),w=grid[0].size();
	
	map<string,int> dp;
	dp[string(w,'$')]=0;
	rep(i,h) rep(j,w){
		map<string,int> dp2;
		for(auto keyval:dp){
			string key=keyval.first;
			if(grid[i][j]!='.' && can_place(key,j,'#')){
				update_max(dp2[place(key,j,'#')],keyval.second+1);
			}
			if(grid[i][j]!='#' && can_place(key,j,'.')){
				update_max(dp2[place(key,j,'.')],keyval.second);
			}
		}
		dp=dp2;
	}
	
	int res=-1;
	for(auto keyval:dp)
		if(all_of(all(keyval.first),[](char c){return c=='0'||c=='.';}))
			update_max(res,keyval.second);
	
	return res;
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		vs grid(h,string(w,' '));
		rep(i,h) cin>>grid[i];
		if(h>w){
			vs temp(w);
			rep(i,h) rep(j,w)
				temp[j]+=grid[i][j];
			grid=temp;
		}
		cout<<solve(grid)<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;



int main() {
	
	int k, s;
	cin >> k >> s;

	ll cnt = 0;

	for (int x = 0; x < k+1; x++)
	{
		for (int y = 0; y < k+1; y++)
		{
			if (0 <= s - x - y and s - x - y <= k) {
				cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 888
use proconio::{input, fastout};
// use itertools::Itertools;

const MOD: u64 = 1_000_000_007;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut ans = 0u64;
    let mut cs = vec![0; a.len()+1];

    for (i, v) in a.iter().enumerate() {
        if i == 0 {
            cs[1] = a[0];
            cs[1] %= MOD;
            continue;
        }
        cs[i+1] += cs[i] + v;
        cs[i+1] %= MOD;
    }

    for i in 1..a.len() {
        // ans += a[0..i].iter().sum::<u64>() * a[i];
        ans += (cs[i] - cs[0]) * a[i];
        ans %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 7292
/*input
1000000000000000000 1
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld n,k;
	cin >> n >> k;
	lld t=n/k;
	n-=t*k; 
	lld k1=abs(n-k);
	cout << min(n,k1) << endl;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    string S = in<string>();
    int counter = 0;
    char before = '1';
    REP(i,N){
        if(before != S[i])counter++;
        before = S[i];
    }
    cout << counter << "\n";
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#define MAXN 105000
#define WTF 1000000007
using namespace std;

int n, k;
int a[MAXN];
int ans[150][MAXN];
int main(){
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        //a[i] = i+1;
    }
    for (int i = 0; i <= a[0]; i++){
        ans[0][i] = 1;
    }
    for (int i = 1; i < n; i++){
        ans[i][0] = ans[i-1][0];
        for (int j = 1; j <= a[i]; j++){
            ans[i][j] = (ans[i-1][j] + ans[i][j-1])%WTF;
        }
        for (int j = a[i]+1; j <= k; j++){
            ans[i][j] = (ans[i][j-1] + ans[i-1][j] - ans[i-1][j-a[i]-1])%WTF;
            if (ans[i][j] < 0){
               ans[i][j] += WTF;
            }
        }
    }
    /*for (int i = 0; i <= n; i++){
        for (int j = 0; j <= k; j++){
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }*/
    cout << ans[n-1][k]%WTF << endl;
}

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

int main() {
  int k, t;
  cin >> k >> t;
  vector<int> v(t);
  rep(i, t) cin >> v[i];
  sort(v.begin(), v.end());
  if(t == 1) cout << k - 1 << endl;
  else if(v[t-1] > (k+1) / 2) cout << (v[t-1] - (k+1) / 2) * 2 - 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
a = [[a[i][0]-a[i][1],a[i][0]+a[i][1]] for i in range(n)]
a.sort(key = lambda x:x[1])
ans = 1
g = a[0][1]
for i in range(1,n):
  x = a[i][0]
  if g<=x:
    ans += 1
    g = a[i][1]
print(ans)

Measured memory_bytes: 40996
#include<stdio.h>

int p[1030];
int main(){
  int a;
  scanf("%d",&a);
  for(int i = 1;i<=a;i++)scanf("%d",p+i);
  for(int i = 1;i<=a;i++){
    printf("node %d: key = %d, ",i,p[i]);
    if(i!=1)printf("parent key = %d, ",p[i/2]);
    if(i*2<=a)printf("left key = %d, ",p[2*i]);
    if(i*2+1<=a)printf("right key = %d, ",p[2*i+1]);
    puts("");
	}
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int H, W;
int N;

int main() {
  cin >> H >> W >> N;
  vector<int> A(N+1);
  for (int i=1; i<N+1; i++) {
    cin >> A.at(i);
  }
  int ans[H][W];
  int pos = 1;
  for (int i=0; i<H; i++) {
    if (i%2==0) {
      for (int j=0; j<W; j++) {
        if (A.at(pos) == 0) {
          pos++;
        }
        ans[i][j] = pos;
        A.at(pos)--;
      }
    } else {
      for (int j=W-1; j>=0; j--) {
        if (A.at(pos) == 0) {
          pos++;
        }
        ans[i][j] = pos;
        A.at(pos)--;
      }
    }
  }

  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cout << ans[i][j];
      if (j!=W-1) {
        cout << ' ';
      }
    }
    if (i!=H-1) {
      cout << endl;
    }
  }
}


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

using namespace std;

int main()
{
    int n; cin >> n;
    int a[3][109];
    int visited[3][109];

    for (int i = 0; i <= 2; i++) {
        for (int j = 0; j <= n; j++) {
            visited[i][j] = 0;
            a[i][j] = 0;
        }
    }

    for (int i = 1; i <= 2; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> a[i][j];
        }
    }

    // search
    for (int i = 1; i <= 2; i++) {
        for (int j = 1; j <= n; j++) {
                visited[i][j] = max(visited[i][j - 1] + a[i][j], visited[i - 1][j] + a[i][j]);
        }
    }

    cout << visited[2][n] << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc130/tasks/abc130_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<ll> S(N),T(M);
    for(auto& in:S) cin >> in;
    for(auto& in:T) cin >> in;
    
    
    auto add = [](ll& t,const ll v){
        (t += v)%=MOD;
    };
    
    // dp[i][j] := [S_1,S_i]及び[T_1,T_j]の二つの文字列を使って作れる共通部分列の総数
    vector<vector<ll>> dp(N+1,vector<ll>(M+1));
    dp[0][0] = 1;
    for(int i = 0; i <= N;i++) dp[i][0] = 1;
    for(int j = 0; j <= M;j++) dp[0][j] = 1;

    
    for(int i = 1; i <= N;i++){
        for(int j = 1; j <= M;j++){
            ll v = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + MOD)%MOD;
            add(dp[i][j],v);
            
            if(S[i-1] == T[j-1]){
                add(dp[i][j],dp[i-1][j-1]);
            }
        }
    }
    
    res = dp[N][M];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    reverse(a.begin(), a.end());

    ll sml = 2,
       big = 2;

    rep(i, n)
    {

        ll mult = (sml + a[i] - 1LL) / a[i];
        ll bigMul = big / a[i];
        sml = mult * a[i];
        big = (bigMul + 1LL) * a[i] - 1LL;
        if (sml > big)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << sml << " " << big << endl;

    return 0;
}

Measured memory_bytes: 1024
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

const static sl NMAX = 100000;
static sl N, K;
using Edge = pair<sl, sl>;
static vector<vector<sl>> Ei;
static vector<Edge> edges;
static map<Edge, sl> colors;
static bool visit[NMAX];
static sl prev_colors[NMAX];

void solve(void) {
  deque<sl> que;

  K = 1;
  visit[0] = true;
  prev_colors[0] = 0;
  que.push_back(0);

  while(!que.empty()) {
    sl idx = que.front();
    que.pop_front();
    sl cur = 0;
    FORITER(Ei[idx], it) {
      if (visit[*it]) {
        continue;
      }
      visit[*it] = true;
      cur++;
      if (cur == prev_colors[idx]) {
        cur++;
      }
      K = max(K, cur);
      colors[make_pair(idx, *it)] = cur;
      colors[make_pair(*it, idx)] = cur;
      prev_colors[*it] = cur;
      que.emplace_back(*it);
    }
  }

  printf("%lld\n", K);
  FORITER(edges, it) {
    printf("%lld\n", colors[*it]);
  }
}

int main(void) {
  scanf("%lld", &N);
  sl a, b;
  Ei.resize(N);
  FOR0(i, N - 1) {
    scanf("%lld %lld", &a, &b);
    a -= 1;
    b -= 1;
    Ei[a].emplace_back(b);
    Ei[b].emplace_back(a);
    edges.emplace_back(a, b);
  }
  solve();
  return 0;
}

Measured memory_bytes: 21488
#include<bits/stdc++.h>
#define ff(i,x,y) for(int i=x;i<=y;i++)
#define fs(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
int vis[2][100010];
int main()
{
    int n;
    scanf("%d",&n);
    ff(i,1,n)
    {
        int now;
        scanf("%d",&now);
        vis[i%2][now]++;
    }
    int mx1=0,s2,s1,mx2=0,m1=0,m2=0;
    ff(i,1,100000)
    {
        if(vis[0][i]&&mx1<=vis[0][i])
        {
            m1=mx1;
            mx1=vis[0][i];
            s1=i;
        }
        else if(vis[0][i]&&mx1>vis[0][i])
        m1=max(m1,vis[0][i]);
        if(vis[1][i]&&mx2<=vis[1][i])
        {
            m2=mx2;
            mx2=vis[1][i];
            s2=i;
        }
        else if(vis[1][i]&&mx2>vis[1][i])
            m2=max(m2,vis[1][i]);
    }
    int ans=n-mx1-mx2;
    if(s1==s2)
    ans=min(n-mx1-m2,n-mx2-m1);
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int i, m, n, initial_fund, year, flg, dec, rst, max, sum;
	double per;

	scanf("%d", &m);
	while (m--) {
		scanf("%d%d%d", &initial_fund, &year, &n);
		max = 0;
		while (n--) {
			scanf("%d%lf%d", &flg, &per, &dec);
			rst = initial_fund;
			for (i = 0, sum = 0; i < year; i++) {
				if (flg == 1) {
					rst = rst + (int)(rst * per) - dec;
				} else {
					sum = sum + (int)(rst * per);
					rst = rst - dec;
				}
			}
			if (flg == 0) {
				rst = rst + sum;
			}
			if (rst > max) {
				max = rst;
			}
		}
		printf("%d\n", max);
	}
	return 0;
}

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


#define debug(x) cerr<< #x << ": "<< x << endl;
#define print(x) cerr<< x << endl;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define REP(i,x,y) for(int i=x;i<y;i++)
#define REPIT(it,A) for(typeof(A.begin()) it = (A.begin()); it!=A.end();it++)
#define fst first
#define snd second
#define sqr(x) ((x)*(x))

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define ones(x) __builtin_popcountll(x)
using namespace std;

typedef pair<int,int> ii ;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<ii> vii;
int a[55], n, p;
ll dp[55][2];
ll go(int pos, int m){
	if(pos == n){
		return m == p;
	}
	if(dp[pos][m] != -1) return dp[pos][m];
	ll val = go(pos + 1, (m + a[pos]) % 2) + go(pos + 1, m);
	return dp[pos][m] = val;
}

int main(){
   fastio;
	cin >> n >> p;
	REP(i,0,n) cin >> a[i];
	REP(i,0,55) REP(j,0,2) dp[i][j] = -1;
	ll res = go(0,0);
	cout<<res<<endl;
   return 0;
}



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

const ll INF = 1e17;
vector<double> xList;
vector<double> yList;

double factorial(int n)
{
    double ret=1;
    for(int i=1; i<=n; i++)
    {
        ret *= (double)i;
    }
    return ret;
}

double calc(const vector<int>& v)
{
    double ret =0;
    double beforex,afterx,beforey,aftery;
    int count=0;
    for (auto i : v) {
        afterx= xList[i-1];
        aftery= yList[i-1];
        if (count==0) {
            beforex= xList[i-1];
            beforey= yList[i-1];          
            count++;
        }
        ret += sqrt(pow(afterx-beforex,2) + pow(aftery-beforey,2));
        beforex= xList[i-1];
        beforey= yList[i-1];         
    }
    return ret;
}

int main() {
    // init
    std::cout<<std::fixed<<std::setprecision(8);

    // input
    int N;
    cin >> N;
    xList.resize(N);
    yList.resize(N);
    vector<int> pgen;
    pgen.resize(N);
    for (int i =0; i<N; i++)
    {
        cin >> xList.at(i);
        cin >> yList.at(i);
        pgen.at(i) = i+1;
    }

    // resolve
    double ans=0;
    do {
        ans += calc(pgen);
    } while (next_permutation(pgen.begin(), pgen.end()));

    cout << ans/factorial(N) << endl;

    return 0;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
if (a-b)%2==0:
    print((b-a)//2)
else:
    x=(min(max(b-1,a-1),max(n-a,n-b)))
    ans=a+(b-a)//2
    ans2=(n-b+1)+(b-a)//2
    print(min(x,ans,ans2))

Measured memory_bytes: 3060
# C
import heapq # 優先度付きキュー(最小値取り出し)
n = int(input())
v = list(map(int, input().split()))
heapq.heapify(v)   # ヒープ化
ans = 0
for i in range(n-1):
    tmp1 = heapq.heappop(v)               # 最小値の取り出し
    tmp2 = heapq.heappop(v)               # 最小値の取り出し
    tmp = (tmp1 + tmp2) / 2
    heapq.heappush(v, tmp)
ans = heapq.heappop(v)               # 最小値の取り出し
print(ans)

Measured memory_bytes: 38384
import Foundation

let s = readLine()!
var c = s.count
var ans = 0
for i in (2...c).reversed() {
  if i % 2 != 0 { continue }
  let strl = s.prefix(i / 2)
  let l = s.index(s.startIndex, offsetBy: i / 2)
  let r = s.index(s.startIndex, offsetBy: i)
  let strr = s[l..<r]
  if strl == strr && i != s.count{
    ans = i
    break
  }
}
print(ans)

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

typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;

const ll MX = 2e3 + 5;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define F0R(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define re(x) cin >> x
#define ps(x) cout << x << "\n";
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (ll)x.size()
#define len(x) (ll)x.length()
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {	
		ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
		// cin.exceptions(cin.failbit); 
		// throws exception when do smth illegal
		// ex. try to read letter llo ll
		if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

ll N, M;
char a[MX][MX];
ll dp[MX][MX];

ll solve(ll i, ll j) {
	if (dp[i][j] != -INF) {
		return dp[i][j];
	}
	if (i == N - 1 && j == M - 1) {
		return 1;
	}


	ll ret = 0;
	if (i + 1 < N && a[i + 1][j] == '.') ret = ((ret % MOD) + (solve(i + 1, j) % MOD)) % MOD;
	if (j + 1 < M && a[i][j + 1] == '.') ret = ((ret % MOD) + (solve(i, j + 1) % MOD)) % MOD;

	return dp[i][j] = ret;
}

int main() {
	F0R(i, MX) F0R(j, MX) dp[i][j] = -INF;
	re(N), re(M);
	F0R(i, N) F0R(j, M) re(a[i][j]);
	ps(solve(0, 0));

}







Measured memory_bytes: 36972
#include <iostream>
#include <cstdio>
const int MAXN = 1e5;
using namespace std;

inline int read() {
	int x = 0, w = 1; char c = ' ';
	while (c < '0' || c > '9') { c = getchar(); if (c == '-') w = -1; }
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return x * w;
}

int n = read(), m = read();

class Ufs {
	public :
		Ufs() { for (int i = 1; i <= n; ++i) fa[i] = i, rk[i] = 1; } 
		int find(int x);
		bool UnionSet(int x, int y, int w);
	private :
		int fa[MAXN + 5], rk[MAXN + 5], v[MAXN + 5];
} S;

int Ufs::find(int x) {
	if (x == fa[x]) return fa[x];
	int t = find(fa[x]);
	v[x] += v[fa[x]];
	fa[x] = t;
	return fa[x];
}

bool Ufs::UnionSet(int x, int y, int w) {
	int p = find(x), q = find(y);
	if (p != q) {
		if (rk[p] < rk[q]) {
			fa[p] = fa[q], v[p] = v[y] - v[x] - w;
		}	
		else {
			if (rk[p] == rk[q]) ++rk[q];
			fa[q] = fa[p], v[q] = v[x] + w - v[y];
		}
	}
	else if (v[y] - v[x] != w)
		return false;
	return true;	
}

int l[MAXN + 5], r[MAXN + 5], d[MAXN + 5];

int main() {;
	for (int i = 1; i <= m; ++i) {
		int L = read(), R = read(), D = read();
		if (!S.UnionSet(L, R, D)) {
			puts("No"); return 0;
		}
	}
		
	puts("Yes");

	return 0;
}

Measured memory_bytes: 1408
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def calc_circumcircle(xa, ya, xb, yb, xc, yc):
    """
    3点の外接円の中心と半径を求める（行列式より）
    """

    A2 = xa ** 2 + ya ** 2
    B2 = xb ** 2 + yb ** 2
    C2 = xc ** 2 + yc ** 2

    sx = ((A2 * yb + ya * C2 + B2 * yc) - (yb * C2 + ya * B2 + A2 * yc)) / 2
    sy = ((xa * B2 + A2 * xc + xb * C2) - (B2 * xc + A2 * xb + xa * C2)) / 2
    a = (xa * yb + ya * xc + xb * yc) - (yb * xc + ya * xb + xa * yc)
    b = (xa * yb * C2 + ya * B2 * xc + A2 * xb * yc) - (A2 * yb * xc + ya * xb * C2 + xa * B2 * yc)

    # 3点が同一直線状にある（三角形ではない）
    if a == 0 or b == 0:
        return None, None, None

    cx, cy = sx / a, sy / a
    r = (b / a + (sx ** 2 + sy ** 2) / a ** 2) ** 0.5
    return cx, cy, r


def main():
    def dist(xf, yf, xs, ys):
        return ((xf - xs) ** 2 + (yf - ys) ** 2) ** 0.5

    N = int(readline())
    EPS = 10 ** (-10)
    ans = INF
    points = []

    for _ in range(N):
        x, y = map(int, readline().split())
        points.append((x, y))

    for i in range(N):
        x1, y1 = points[i]
        for j in range(i + 1, N):
            x2, y2 = points[j]
            xc, yc = (x1 + x2) / 2, (y1 + y2) / 2
            r = dist(x1, y1, x2, y2) / 2
            for k in range(N):
                x3, y3 = points[k]
                d = dist(x3, y3, xc, yc)
                if d > r + EPS:
                    break
            else:
                ans = min(ans, r)

    import math

    for i in range(N):
        x1, y1 = points[i]
        for j in range(i + 1, N):
            x2, y2 = points[j]
            for k in range(j + 1, N):
                x3, y3 = points[k]
                cx, cy, r = calc_circumcircle(x1, y1, x2, y2, x3, y3)
                if cx is None:
                    continue
                for l in range(N):
                    x4, y4 = points[l]
                    d = dist(x4, y4, cx, cy)
                    if d > r + EPS:
                        break
                else:
                    ans = min(ans, r)

    print(ans)


if __name__ == '__main__':
    main()


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

const int BS=60;

const long long MS=(1ll<<BS)-1ll;
int main()
{
  int n;
  scanf("%d",&n);
  vector<int> a(n);
  int A=0;
  for(int i=0;i<n;i++){
    scanf("%d",&(a[i]));
    A+=a[i];
  }
  static long long T[5000000/BS]={0};
  T[0]=1;
  for(int i=0;i<n;i++){
    int s=a[i]/BS,t=a[i]%BS;
    for(int k=A/BS;k>=0;k--){
      T[k+s+1]|=(T[k]>>(BS-t));
      T[k+s]|=((T[k]&((1ll<<(BS-t))-1ll))<<t);
    }
  }
  int ret;
  for(int k=(A+1)/2;;k++){
    if((T[k/BS]>>(k%BS))&1){
      ret=k;
      break;
    }
  }
  printf("%d\n",ret);
  return 0;
}


Measured memory_bytes: 768
parseInt(s) = parse(Int, s)

function solve()
    N,X,M=map(parseInt,split(readline()))
    D=zeros(Int,(M,2))
    #print(D)
    ans = 0
    i_loop=-1
    An=X
    for i = 1:N
        if An==0
            break
        end
        if D[An,1]!=0
            i_loop=i
            break
        end
        ans += An
        D[An,1]=i
        D[An,2]=ans
        #i+1
        An = (An^2)%M
    end
    if i_loop<0
        println(ans)
    else
        ans_b=D[An,2]-An
        ans_loop=ans-ans_b
        #
        n_loop=i_loop-D[An,1]
        #
        n_b=D[An,1]-1
        n=N-n_b
        m=div(n, n_loop)
        r=n%n_loop
        ###
        ans = ans_b + m*ans_loop
        for i = 1:r
            ans+=An
            An=(An^2)%M
        end
        println(ans)
    end
end

solve()

Measured memory_bytes: 167604
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            bool flag = true;
            for(int i = 0; i< a.Count()-1;i++){
                if(a[i] == a[i+1]){
                    flag = false;
                    break;
                }
            }
            Console.WriteLine(flag?"Good":"Bad");
        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 26080
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, H = Scanner.map_int()
    A = [0] * N
    B = [0] * N
    for i in range(N):
        a, b = Scanner.map_int()
        A[i] = a
        B[i] = b
    A.sort(reverse=True)
    B.sort(reverse=True)
    ans = 0
    for i in range(N):
        if B[i] > A[0]:
            ans += 1
            H -= B[i]
            if H <= 0:
                break
        else:
            break
    H = max(0, H)
    ans += Math.roundUp(H, A[0])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44380
import sys
import math
t1, t2 = [int(i) for i in sys.stdin.readline().split()]
a1, a2 = [int(i) for i in sys.stdin.readline().split()]
b1, b2 = [int(i) for i in sys.stdin.readline().split()]
a1 -= b1
a2 -= b2
_sum = a1 * t1 + a2 * t2
if _sum == 0:
    print("infinity")
elif _sum * a1 > 0:
    print("0")
else:
    cnt = (-a1 * t1) / _sum
    res = math.ceil(cnt) * 2 - 1 + (cnt % 1 == 0)
    print(res)

Measured memory_bytes: 38256
import java.util.Scanner;

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

    String s = scanner.next();
    if (s.length() > 2) {
      for (int i = 0; i < s.length(); i++) {
        System.out.print(s.charAt(s.length() - i - 1));
      }
      System.out.println();
    } else {
      System.out.println(s);
    }
  }
}


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

int main() {
   long long a,b,c,d;
   cin >> a >> b >> c >> d;
   if ((a<=0 && c<=0) || (b>=0 && d>=0)) cout << max(a*c,b*d) << endl;
   else cout << max(a*d,b*c) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> g(h,vector<char>(w));
  rep(i,h)rep(j,w)cin >> g[i][j];
  vector<bool> row(h,0);
  vector<bool> col(w,0);
  rep(i,h)rep(j,w)if(g[i][j]=='#'){
    row[i]=1;
    col[j]=1;
  }
  rep(i,h){
    if(!row[i])continue;
    rep(j,w){
      if(!col[j])continue;
      cout << g[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
if b*a**2 == x:
    print("0")
elif x >= (b*a**2)/2:
    print(90-math.degrees(math.atan(a**3/(2*(b*a**2-x)))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b**2))))

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int N;
  int i,j,k;
  int v;

  scanf("%d",&N);

  int A[N];

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
 A[i]='\0';
  
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);

  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0;k<N-1;k++){
      printf("%d ",A[k]);
    }
    printf("%d\n",A[k]);
  }
  return 0;
}
  



Measured memory_bytes: 2084
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String d1, d2, d3, d4, d5, d6;
        d1 = scn.next();
        d2 = scn.next();
        d3 = scn.next();
        d4 = scn.next();
        d5 = scn.next();
        d6 = scn.next();

        String c1, c2, c3, c4, c5, c6;
        c1 = scn.next();
        c2 = scn.next();
        c3 = scn.next();
        c4 = scn.next();
        c5 = scn.next();
        c6 = scn.next();

        if (c1.equals(d1)&&c6.equals(d6)) {
            String cube = d2 + d3 + d5 + d4;
            cube = cube + cube;
            String check = c2 + c3 + c5 + c4;
            if(cube.contains(check)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }else if (c1.equals(d6)&&c6.equals(d1)) {
            String cube = d4 + d5 + d3 + d2;
            cube = cube + cube;
             String check = c2 + c3 + c5 + c4;
            if(cube.contains(check)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }else if (c1.equals(d2)&&c6.equals(d5)) {
            String cube = d4 + d6 + d3 + d1;
            cube = cube + cube;
            String check = c2 + c3 + c5 + c4;
            if(cube.contains(check)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }else if (c1.equals(d5)&&c6.equals(d2)) {
            String cube = d1 + d3 + d6 + d4;
            cube = cube + cube;
            String check = c2 + c3 + c5 + c4;
            if(cube.contains(check)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }else if (c1.equals(d3)&&c6.equals(d4)) {
            String cube = d1 + d2 + d6 + d5;
            cube = cube + cube;
            String check = c2 + c3 + c5 + c4;
            if(cube.contains(check)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }else if (c1.equals(d4)&&c6.equals(d3)) {
            String cube = d5 + d6 + d2 + d1;
            cube = cube + cube;
            String check = c2 + c3 + c5 + c4;
            if(cube.contains(check)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }else{
            System.out.println("No");
        }



        scn.close();

    }


}



Measured memory_bytes: 26256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se>b.se;
}
ll cmp(ll a,ll b){
    return abs(a)<abs(b);
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll nn,mm,dd;cin>>nn>>mm>>dd;
    double n=nn,m=mm,d=dd;
    double ans;
    if(dd>0){
        if(dd<=nn/2){
            ans = 2.0*(n-d)*(m-1.0)/(n*n);
        }
        else if(dd<n){
            ans = 2.0*(n-d)*(m-1.0)/(n*n);
        }
        else{
            ans=0.0;
        }
    }
    else{
        ans=(m-1.0)/n; 
    }
    printf("%.10lf\n",ans);
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------






















































Measured memory_bytes: 3648