akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

typedef long long ll;

ll dp[3005][3005];
ll a[3005];
ll mod = 998244353;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,s;
	cin >> n >> s;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= s; j++)
		{
			dp[i][j] = (dp[i-1][j] * 2) % mod;
			if( j >= a[i] ) dp[i][j] += dp[i-1][j-a[i]];
			dp[i][j] %= mod;
		}
 	}
 	cout << dp[n][s] << '\n';
	return 0;
}


Measured memory_bytes: 73608
def test():
    a = int(input())
    count = 0
    result = 0
    for i in range(1,a+1):
        num = i
        while num % 2 == 0:
            num //= 2
            count += 1
        if result < count:
            result = count
            a = i
        count = 0
    print(a)



if __name__ == "__main__":
    test()


Measured memory_bytes: 2940
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())
print((N-1)*N//2)

Measured memory_bytes: 77228
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const bool debug = 0;
//---------------------------------//

typedef tuple<int, int, int> int3;

int N, M;
int A[2000], B[2000];
vector<int> g[1000];
bool left_[1000];

int indeg[1000];

bool solve() { // 閉路が存在するか
	memset(indeg, 0, sizeof(indeg));
	
	REP(i, M) if (left_[A[i]] && left_[B[i]]) {
		indeg[B[i]]++;
	}
	
	
	queue<int> que;
	REP(i, N) if (left_[i] && indeg[i] == 0) que.push(i);
	
	while (!que.empty()) {
		int u = que.front(); que.pop();
		
		for (int v : g[u]) if (left_[v]) {
			if (--indeg[v] == 0) que.push(v);
		}
	}
	
	REP(i, N) if (left_[i] && indeg[i]) return true;
	return false;
}

int main() {
	cin >> N >> M;
	REP(i, M) {
		scanf("%d %d", A + i, B + i);
		A[i]--; B[i]--;
		g[A[i]].emplace_back(B[i]);
	}
	
	REP(i, N) left_[i] = true;
	if (!solve()) {
		puts("-1");
		return 0;
	}
	REP(i, N) {
		left_[i] = false;
		if (!solve()) left_[i] = true;
	}
	
	vector<int> ans;
	REP(i, N) if (left_[i]) ans.emplace_back(i);
	cout << ans.size() << endl;
	for (int u : ans) printf("%d\n", u + 1);
	
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		String s = ((double)x == (double)W/(double)2 &&
					(double)y == (double)H/(double)2) ? "1" : "0";
		double area = (double)W*(double)H/2;
		String a = String.format("%.6f", area);
		System.out.println(a+" "+s);
	}
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();

  ll dp[n+1][2][k+3];
  rep(i, n+1) rep(j, 2) rep(t, k+3) dp[i][j][t] = 0;

  dp[0][0][0] = 1;

  rep(i, n) {
    int x = s[i]-'0';
    rep(j, 2) {
      for(int t = 0; t <= k; ++t) {
        rep(c, (j?10:x+1)) dp[i+1][j || c < x][t + (c?1:0)] += dp[i][j][t];
      }
    }
  }
  ll ans = dp[n][0][k] + dp[n][1][k];
  cout << ans << endl;
}

Measured memory_bytes: 3600
N=int(input())
a=list(map(int,input().split()))

a=sorted(a)
l=a[0]
cnt=0

b=[]
for i in range(N):
    if a[i]==l:
        cnt+=1
    else:
        b.append([l,cnt])
        l=a[i]
        cnt=1
if cnt>0:
    b.append([l,cnt])

ans=0
for i in range(len(b)):
    if b[i][0]>b[i][1]:
        ans+=b[i][1]
    else:
        ans+=b[i][1]-b[i][0]

print(ans)

Measured memory_bytes: 21524
#include <iostream>
using namespace std;
int main(void){
    
    int a[5]={};
    int mi=10,d=0,ans=0;
    
    for(int i=0;i<5;i++){
        cin>>a[i];
        int b=a[i]%100;
        int c=b%10;
        if(c<mi && c!=0) mi=c;
        d=a[i];
        if(c!=0) ans+=10-c+a[i];
        else ans+=a[i];
    }
    cout<<ans-(10-mi)<<endl;
    return 0;
}


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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(s * t >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;

int main()
{
    int n, q, x;
    int ans = 0;
    vector<int> a, b;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        a.push_back(x);
    }
    cin >> q;
    for (int j = 0; j < q; j++)
    {
        cin >> x;
        b.push_back(x);
    }
    for (vector<int>::iterator it = b.begin(); it != b.end(); it++)
    {
        if (binary_search(a.begin(), a.end(), *it))
            ans++;
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 3548
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
int main() {
	map<int, ll>S,T;
	string s, t;
	cin >> s >> t;
	int mins=200,maxt=0;
	rep(i, s.size()) {

		S[(int)s[i]]++;
		mins = min(mins, (int)s[i]);
	}
	rep(i, t.size()) {
		T[(int)t[i]];
		maxt = max(maxt, (int)t[i]);
	}
	if (maxt > mins || (maxt == mins && T[maxt] > S[maxt])||(S.size()==1&&T.size()==1&&t.size()>s.size())) {

		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
}

Measured memory_bytes: 256
#coding:utf-8
N = int(input())
A = [int(i) for i in input().split()]

A.sort(reverse = True)

k = N-2
index = 1
ans = A[0]

while k > 0:
    if k > 1:
        k -= 2
        ans += A[index] * 2
    elif k == 1:
        k -= 1
        ans += A[index]
    index += 1

print("{}".format(ans))

Measured memory_bytes: 31448
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using ll = boost::multiprecision::cpp_int;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)
//using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1 ,rr =1;
    for(ll i=0;i<k;++i) {
      r*=(n-i);
      rr*=(i+1);
      //r %= 1000000007;
      //rr %= 1000000007;
    }
    r/=rr;
    //r %= 1000000007;
    return r;
}
int main() {
  ll N,A,B;
  cin>>N>>A>>B;
  ll min = A*N;
  if(min>B)min = B;
  cout<<min<<endl;
  
  return 0;
}


Measured memory_bytes: 888
s=int(input())

b=int(s%1000)
a=int((s-b)/1000)
d=int(b%100)
c=int((b-d)/100)
f=int(d%10)
e=int((d-f)/10)

if a==c or c==e or e==f :
    print("Bad")
else:
    print("Good")


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

const int N = 100010;
typedef long long ll;
int A[N] , B[N];

int n , m;
vector<int> adj[N] , son[N];

struct Cmp {  bool operator() (int x , int y) const {return A[x] < A[y];} };

int par[N] , id[N] , vis[N];
int find(int x) {return x == par[x] ? x : par[x] = find(par[x]);}

ll dp[N] , s[N];
void dfs(int x) {
    s[x] = B[x];
    for(auto y : son[x]) dfs(y) , s[x] += s[y];
    dp[x] = A[x] + s[x];
    for(auto y : son[x]) dp[x] = min(dp[x] , max(dp[y] , (ll)A[x]) + s[x] - s[y]);
}
int main() {
    scanf("%d %d" , &n , &m);
    for(int i = 1 ; i <= n ; ++i) {
        scanf("%d %d" , A + i , B + i);
        A[i] = max(A[i] - B[i] , 0);
        par[i] = i , id[i] = i;
    }
    sort(id + 1 , id + 1 + n , Cmp());
    for(int i = 1 , x , y; i <= m ; ++i) {
        scanf("%d %d" , &x , &y);
        adj[x].push_back(y) , adj[y].push_back(x);
    }
    for(int i = 1 ; i <= n ; ++i) {
        int x = id[i];
        vis[x] = 1;
        for(auto y : adj[x])
            if(vis[y]) {
                int z = find(y);
                if(z != x) son[x].push_back(z) , par[z] = x;
            }
    }
    dfs(id[n]) , cout << dp[id[n]] << endl;
}

Measured memory_bytes: 19856
# 約数s
def make_divisors(n):
    divisors = []
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append((i,n//i))
    return ret

if __name__ == "__main__":
    n = int(input())
    ret = make_divisors(n)
    # print(ret)
    ans = 10**18
    for a,b in ret:
        ans = min(a+b, ans)
    print(ans-2)

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

int main() {
    int64_t N, K, ans;
    cin >> N >> K;
    ans = 0;

    if (N % K == 0) {
        ans = 0;
    }
    else {
        N %= K;
        ans = min (N, abs (N - K));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  int n;
  while(cin>>n,n){
    int re[n];
    rep(i,n)cin>>re[i];
    int oh=32;
    bool ban=true;
    int ji=0;
    while(oh){
      if(ban){
        oh-=(oh+4)%5;
        cout<<oh<<endl;
      }else{
        oh-=re[ji++%n];
        if(oh<0)oh=0;
        cout<<oh<<endl;
      }
      ban=!ban;
    }
  }
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, h: "List[int]"):
    h.sort()
    print(min(h[i+K-1]-h[i] for i in range(N-K+1)))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7480
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()

l = a[n-1]
r = a[0]
o = abs(l - r)
for i in range(n//2):
    o += abs(r - a[i])
    o += abs(l - a[n-i-1])
    l = a[i]
    r = a[n-i-1]
if n%2 != 0:
    i = n//2
    o += max(abs(l-a[i]) , abs(r-a[i]))


print(o)

Measured memory_bytes: 7504
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Array.Unboxed
import Data.Array.ST
import Control.Monad.ST

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine


main = do
    [n,m,q] <- getIntList
    lr <- replicateM m $ do
        [l,r] <- getIntList
        return (l,r)
    pq <- replicateM q $ do
        [p,q] <- getIntList
        return (p,q)
    let result = runSTUArray $ do
            arr <- newArray ((1,1),(n,n)) (0 :: Int)
            forM_ lr $ \(l,r) -> do
                forM_ [1..l] $ \x -> do
                    a <- readArray arr (x,r)
                    writeArray arr (x,r) $ a + 1
            forM_ [1..n-1] $ \x -> do
                forM_ [x+1..n] $ \y -> do
                    a <- readArray arr (x,y-1)
                    b <- readArray arr (x,y)
                    writeArray arr (x,y) $ a + b
            return arr
    forM_ pq $ \(p,q) -> do
        print $ result ! (p,q)

Measured memory_bytes: 104716
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
P=list(map(int,input().split()))
f=10**10
ans=0
for i in range(-120,220):
  if i not in P:
    a=abs(x-i)
    if a<f:
      f=a
      ans=i
print(ans)


Measured memory_bytes: 61700
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(ll N, vector<string> S) {
  unordered_map<string, ll> count;
  REP(i, N)
    count[S[i]]++;

  printf("AC x %lld\n", count["AC"]);
  printf("WA x %lld\n", count["WA"]);
  printf("TLE x %lld\n", count["TLE"]);
  printf("RE x %lld\n", count["RE"]);
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  vector<string> S(N);
  REP(i, N) {
    cin >> S[i];
  }

  solve(N, move(S));

  return 0;
}


Measured memory_bytes: 6368
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long N, std::vector<long long> A) {
  vector <pair <LL, LL> > p(N);
  REP(i, N){
    p[i] = make_pair(i+1, A[i]);
  }
  sort(ALL(p), compare_by_b);
  REP(i, N){
    if(i!=N-1)cout<<p[i].first<<" ";
    else cout<<p[i].first<<endl;
  }
  return;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


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

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

    std::string S;
    std::cin >> S;

    int K;
    std::cin >> K;

    for(int i = 0; S[i] != '\0'; i++){
        if(S[i] != S[K-1]){
            S[i] = '*';
        }
    }

    std::cout << S;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    b[i]=a[i]-(i+1)

b.sort()

b2=b[n//2]

bsum=0
for i in range(n):
    bsum+=abs(b[i]-b2)
    
bsum2=0
for i in range(n):
    bsum2+=abs(b[i]-b2-1)

print(min(bsum,bsum2))


Measured memory_bytes: 26020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
            ll a;cin>>a;
            vector<ll>v1(a);
            rep(i,a){
                     cin>>v1[i];
                     }
            ll b;cin>>b;
            vector<ll>v2(b);
            rep(i,b){
                     cin>>v2[i];
                     }
            ll step=0;        
            rep(i,b){
                      if(binary_search(v1.begin(),v1.end(),v2[i])==1){
                                                                      step++;
                                                                      }
                    }
            cout<<step<<endl;

}




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

typedef pair <long long, long long> pii;

const long long MAX_N = 1e5 + 5;
long long n, root;
long long Arr[MAX_N];
long long h[MAX_N];
long long Siz[MAX_N];
long long Mark[MAX_N];
long long par[MAX_N];
unordered_map <long long, long long> Map;
vector <pii> edge;
long long dp_d[MAX_N];
long long dp_u[MAX_N];
vector <long long> child[MAX_N];

bool cmp(long long a, long long b) {
	return Arr[b] < Arr[a];
}

void dfs1(long long v) {
	for (long long i = 0; i < child[v].size(); i++) {
		dfs1(child[v][i]);
		dp_d[v] += dp_d[child[v][i]] + Siz[child[v][i]];
	}
}

void dfs2(long long v, long long val) {
	dp_u[v] = val;
	for (long long i = 0; i < child[v].size(); i++)
		dfs2(child[v][i], dp_d[v] - dp_d[child[v][i]] - Siz[child[v][i]] + dp_u[v] + (n - Siz[child[v][i]]));
}

int main() {
	ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
	cin >> n;
	for (long long i = 0; i < n; i++) {
		cin >> Arr[i];
		Siz[i] = 1;
		h[i] = i;
		Map[Arr[i]] = i;
	}
		
	sort(h, h + n, cmp);
	
	for (long long i = 0; i + 1 < n; i++) {
		long long v = h[i];
		long long tmp = Arr[v] + Siz[v] - (n - Siz[v]);

		if (tmp < 0 || (Map[tmp] == 0 && Arr[0] != tmp)) {
			cout << -1 << "\n";
			return 0;
		}
		
		long long u = Map[tmp];
		/*if (Mark[u]) {
			cout << -1 << "\n";
			return 0;
		}*/
		
		Siz[u] += Siz[v];
		par[v] = u;
		edge.push_back({v, u});
		child[u].push_back(v);
		if (n < 2LL * Siz[v]) {
			cout << -1 << "\n";
			return 0;
		}
		//Mark[v] = true;
	}
	root = h[n - 1];
	dfs1(root);
	//dfs2(root, 0);
	
	for (long long i = root; i < root + 1; i++)
		if (dp_d[i] + dp_u[i] != Arr[i]) {
			cout << -1 << "\n";
			return 0;
		}
	
	for (long long i = 0; i + 1 < n; i++)
		cout << edge[i].first + 1 << " " << edge[i].second + 1 << "\n";
	return 0;
}

Measured memory_bytes: 20380
#include <iostream>
using namespace std;
const int INF = 1 << 29;
const int N_MAX = 41;
const int a_MAX = 11;
const int b_MAX = 11;
const int c_MAX = 100;

typedef struct{ //
  int a; // 物質aの重さ
  int b; // 物質bの重さ
  int c; // 値段
} drug;

int dp[N_MAX][a_MAX*N_MAX][b_MAX*N_MAX];
drug drugs[N_MAX];

int calcDp(int i,int ca,int cb){
  int tmp1,tmp2;
  tmp2 = INF;
  tmp1 = dp[i-1][ca][cb]; //drug iを入れない場合
  if(ca-drugs[i].a >= 0 && cb-drugs[i].b >=0){
    tmp2 = dp[i-1][ca-drugs[i].a][cb-drugs[i].b] + drugs[i].c;
  }
  if(tmp1 <= tmp2) return tmp1;
  else return tmp2;
}

int main(){
  int N,N_a,N_b;
  cin >> N >> N_a >> N_b;
  
  for(int i=0;i<N;i++){
    int a,b,c;
    cin >> a >> b >> c;
    drugs[i].a = a;
    drugs[i].b = b;
    drugs[i].c = c;
  }
  
  for(int i=0;i<N;i++)
    for(int j=0;j<a_MAX*N_MAX;j++)
      for(int k=0;k<b_MAX*N_MAX;k++) dp[i][j][k] = INF;

  dp[0][drugs[0].a][drugs[0].b] = drugs[0].c;
  dp[0][0][0] = 0;

  for(int i=1;i<N;i++)
    for(int ca=0;ca<a_MAX*N_MAX;ca++)
      for(int cb=0;cb<b_MAX*N_MAX;cb++)
	dp[i][ca][cb] = calcDp(i,ca,cb);

  int ans = INF;
  for(int ca=0;ca<a_MAX*N_MAX;ca++)
    for(int cb=0;cb<b_MAX*N_MAX;cb++)
      if((ca*N_b == cb*N_a) && ca != 0 && cb != 0)
	if(ans > dp[N-1][ca][cb]) ans = dp[N-1][ca][cb];

  if(ans == INF) ans = -1;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 32000
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>

#define long long long

using namespace std;

const int N = 2e5 + 2;
const int LN = 18;
const long MOD = 1e9 + 7;

int n, par[LN][N], h[N], in[N], out[N], pw[N], tme = 0, leaf[N];
vector<int> g[N], lv[N];
long f[2][N], res;

int LCA(int u, int v)
{
	if (h[u] < h[v]) swap(u, v);
	for (int i = LN - 1; i >= 0; --i)
		if (h[u] - (1 << i) >= h[v]) u = par[i][u];
	if (u == v) return u;
	for (int i = LN - 1; i >= 0; --i)
		if (par[i][u] != par[i][v])
			u = par[i][u], v = par[i][v];
	return par[0][u];
}

void Dfs(int u) { in[u] = ++tme; for (int v: g[u]) Dfs(v); out[u] = tme; }

void Prep()
{
	Dfs(0);
	pw[0] = 1;
	for (int i = 1; i <= n; ++i) pw[i] = pw[i - 1] * 2 % MOD;
}

long Pow(long x, long n)
{
	long t = 1;
	for (; n > 0; n >>= 1)
	{
		if (n & 1) t = t * x % MOD;
		x = x * x % MOD;
	}
	return t;
}
inline long Inverse(long x) { return Pow(x, MOD - 2); }

void Dfs2(int u)
{
	if (g[u].empty())
	{
		f[0][u] = f[1][u] = leaf[u] = 1;
		return;
	}
	long mul = 1;
	for (int v: g[u])
	{
		Dfs2(v);
		leaf[u] += leaf[v];
		mul = mul * f[0][v] % MOD;
	}
	for (int v: g[u])
		f[1][u] += mul * Inverse(f[0][v]) % MOD * f[1][v] % MOD;
	f[1][u] %= MOD;
	f[0][u] = (pw[leaf[u]] - f[1][u] + MOD) % MOD; 
}

long Solve(vector<int> &a)
{
	int m = a.size();
	sort(a.begin(), a.end(), [](int x, int y) { return in[x] < in[y]; });
	for (int i = 0; i < m - 1; ++i) a.push_back(LCA(a[i], a[i + 1]));
	sort(a.begin(), a.end(), [](int x, int y) { return in[x] < in[y]; });
	a.resize(unique(a.begin(), a.end()) - a.begin());
	
	int n = a.size();
	for (int i = 0; i < n; ++i)
	{
		g[a[i]].clear();
		f[0][a[i]] = f[1][a[i]] = leaf[a[i]] = 0;
	}
	stack<int> s;
	for (int u: a)
	{
		while (!s.empty() && out[s.top()] < in[u]) s.pop();
		if (!s.empty()) g[s.top()].push_back(u);
		s.push(u);
	}
	Dfs2(a[0]);
	return f[1][a[0]];
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) 
	{
		scanf("%d", &par[0][i]);
		g[par[0][i]].push_back(i);
		h[i] = h[par[0][i]] + 1;
		for (int j = 1; j < LN; ++j) 
			par[j][i] = par[j - 1][par[j - 1][i]];
		lv[h[i]].push_back(i);
	}
	Prep();
	res = pw[n];
	for (int i = 1; !lv[i].empty(); ++i)
		res = (res + pw[n + 1 - lv[i].size()] * Solve(lv[i])) % MOD;
	printf("%lld", res);
	return 0;
}


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

#ifdef DEBUG
#include ".inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int a;
    string s;
    cin >> a >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


N = int(input())
S = input()

M = 10**9 + 7
count_dict = defaultdict(int)

for s in S:
    count_dict[s] += 1

ans = 1
for v in count_dict.values():
    ans *= (v + 1)
    ans %= M

print(ans - 1)


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

int main(){
	std::string S; std::cin >> S;
	bool n = 0;
	bool s = 0;
	bool e = 0;
	bool w = 0;
	for (auto& r : S) {
		if (r == 'N')
			n = 1;
		if (r == 'S')
			s = 1;
		if (r == 'E')
			e = 1;
		if (r == 'W')
			w = 1;
	}
	if (n == s && e == w)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> ok(30,0);
    for(int i=0; i<28; i++){
        int a;
        cin >> a;
        ok[a-1]++;
    }
    for(int i=0; i<30; i++){
        if(!ok[i]) cout << i+1 << enld;
    }
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int H,W; cin >> H >> W;
    char s[H][W]; int n_dot=0;
    REP(i,H)REP(j,W){
        cin >> s[i][j];
        if(s[i][j] == '.') n_dot++;
    }
    int dist[H][W]; REP(i,H)REP(j,W) dist[i][j] = (int)INF;
    queue<pair<P,int>> q;
    q.push(pair<P,int>(P(0,0), 0));
    while(q.size()){
        auto p = q.front(); q.pop();
        int x = p.first.first, y = p.first.second, cost = p.second;
        if(s[x][y] == '#') continue;
        if(chmin(dist[x][y], cost)){
            if(x) q.push(MP(P(x-1,y), cost+1));
            if(y) q.push(MP(P(x,y-1), cost+1));
            if(x < H-1) q.push(MP(P(x+1,y), cost+1));
            if(y < W-1) q.push(MP(P(x,y+1), cost+1));
        }
    }
    if(dist[H-1][W-1] == INF){
        cout << -1 << endl;
    }
    else{
        cout << n_dot - dist[H-1][W-1]- 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int m, f, r;
	while (1)
	{
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;
		if (m == -1 || f == -1 ||(m + f) < 30)
		{
			printf("F\n");
		}
		else if (m + f >= 80)
		{
			printf("A\n");
		}
		else if (m + f >= 65)
		{
			printf("B\n");
		}
		else if ((m + f >= 50) || (r >= 50))
		{
			printf("C\n");
		}
		else 
		{
			printf("D\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
int main() {
int A,B,C,x;
scanf("%d %d %d %d",&A,&B,&C,&x);
int cnt=0;
int a,b,c;
  for(a=0;a<=A;a++){
    for(b=0;b<=B;b++){
      for(c=0;c<=C;c++){
        int sum=500*a+100*b+50*c;
        if(sum==x){
          cnt++;
        }
      }
    }
  }
  printf("%d",cnt);
  return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

str_n = str(n)

tot = 0

for ch in str_n:
    tot += int(ch)

if tot%9 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9192
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

bool is_ok(v2int& X) {
 
    rep(i, 3) {
        int s = 0;
        rep(j, 3) {
            s += X[i][j];
        }
        if (s == 3) {
            return true;
        }
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    v2int A(3, vint(3));
    rep(i, 3) {
        rep(j, 3) cin >> A[i][j];
    }
    int N;
    cin >> N;
    vint b(N);
    rep(i, N) cin >> b[i];
    v2int X(3, vint(3, 0));
    v2int XT(3, vint(3, 0));
    rep(n, N) {
        rep(i, 3) {
            rep(j, 3) {
                if (A[i][j] == b[n]) {
                    X[i][j] = 1;
                    XT[j][i] = 1;
                }

            }
        }
    }
    
    if (is_ok(X) == true) {
        cout << "Yes" << endl;
        return 0;
    }
    if (is_ok(XT) == true) {
        cout << "Yes" << endl;
        return 0;
    }
    int s = 0;
    rep(i, 3) {
        s += X[i][i];
    }
    if (s == 3) {
        cout << "Yes" << endl;
        return 0;
    }
    s = 0;
    rep(i, 3) {
        s += X[2 - i][i];
    }
    if (s == 3) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def solve(a, b):
    m = min(a, b)
    n = max(a, b)
    return "".join([str(m)] * n)


def main():
    a, b = map(int, input().split())
    res = solve(a, b)
    print(res)


def test():
    assert solve(4, 3) == "3333"
    assert solve(7, 7) == "7777777"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> v(26);
    int len = s.size();
    rep(i, 0, len) v[s[i] - 'a'].push_back(i);
    rep(i, 0, len) v[s[i] - 'a'].push_back(i + len);
    ll ans = 0;
    int p = 0;
    rep(i, 0, t.size()) {
        int c = t[i] - 'a';
        if ((int)v[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(all(v[c]), p) + 1;
        if (p > len) {
            ans += len;
            p -= len;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1724
N, P = map(int, input().split())

pl = []
d = {}

p = P
i = 2
while i * i <= P:
    cnt = 0
    while p % i == 0:
        p //= i
        cnt += 1
    if cnt > 0:
        d[i] = cnt
    i += 1

if p != 0:
    d[p] = 1

ans = 1
for k, v in d.items():
    ans *= (k ** (v // N))

print(ans)

Measured memory_bytes: 40172
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<String> testScore = new ArrayList<String>();
    int m = 0;
    int f = 0;
    int r = 0;
    while (true) {
      m = sc.nextInt();
      f = sc.nextInt();
      r = sc.nextInt();
      if(m == -1 && f == -1 && r == -1){
        //testScore.add("");
         break;
      }else if (m == -1 || f == -1) {
        testScore.add("F");
      } else if ((m + f) >= 80) {
        testScore.add("A");
      } else if ((m + f) >= 65 && (m + f) < 80) {
        testScore.add("B");
      } else if ((m + f) >= 50 && (m + f) < 65 || r >= 50) {
        testScore.add("C");
      } else if ((m + f) >= 30 && (m + f) < 50 && r < 50) {
        testScore.add("D");
      } else if ((m + f) < 30) {
        testScore.add("F");
      }
    }

    for(String testResult: testScore){
      System.out.println(testResult);
    }

  }
}


Measured memory_bytes: 26320
import math
a,b,x=map(int,input().split())

s=x/a

if s >= a*b/2:
    h=(a*b-s)*2/a
    rad= math.atan2(h,a)
else:
    w=s*2/b
    rad =math.atan2(b,w)

print(math.degrees(rad))

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

void exchange(long long int &x, long long int &qnt, long long value) {
	if(x >= value) {
		qnt = x / value;
		x = x % value;
	}
}

int main() {
	long long int x, a = 0, b = 0;
	cin >> x;
	exchange(x, a, 500);
	exchange(x, b, 5);
	cout << ((a * 1000) + (b * 5)) << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

fn main() {
    let (h,w) = {
        let xs = read_vec_i64();
        (xs[0] as usize, xs[1] as usize)
    };
    let field = {
        let mut field = vec![];
        for _ in 0..h {
            let ss: Vec<char> = read_line().chars().collect();
            field.push(ss);
        }
        field
    };
    let mut empty_xs = vec![true; w];
    let mut empty_ys = vec![true; h];
    for y in 0..h {
        for x in 0..w {
            if field[y][x] == '#' {
                empty_xs[x] = false;
                empty_ys[y] = false;
            }
        }
    }
    for y in 0..h {
        if ! empty_ys[y] {
            for x in 0..w {
                if ! empty_xs[x] {
                    print!("{}", field[y][x]);
                }
            }
            println!();
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
namespace ITP1_10_A
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }


        public static void Main (string[] args)
        {

            List<string[]> list_result = new List<string[]>();
            list_result = getinputdata();

            double x1 =double.Parse(list_result[0][0]);
            double y1 =double.Parse(list_result[0][1]);
            double x2 =double.Parse(list_result[0][2]);
            double y2 =double.Parse(list_result[0][3]);

            double distance = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));

            Console.WriteLine(distance);




        }

    }
}

Measured memory_bytes: 9540
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define reset(x) memset(x,0,sizeof x)
#define sz(x) x.size()
#define pb push_back
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;


















int main() {

    float T,X;
    cin >> T >> X;
    cout << fixed << setprecision(7) << T/X;
    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point
{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(x * a, y * a);}
    Point operator / (double a) {return Point(x / a, y / a);}

    double abs() {return sqrt(norm());}
    double norm() {return x * x + y * y;}
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
};typedef Point Vector;

struct Segment {
    Point p1, p2;
};

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
    return isOrthogonal(a1 - a2, b1 - b2);
}

bool isParallel(Vector a, Vector b){
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
    return isParallel(a1 - a2, b1 - b2);
}
#include<iostream>
#include<iomanip>
using namespace std;
Point projection(Segment s, Point p){
    Vector base = s.p2 - s.p1;
    double r = dot(p-s.p1, base) / base.norm();
    return s.p1 + base * r;
}
int main(){
    int x1, y1, x2, y2, q;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    Point p1 = Point(x1, y1), p2 = Point(x2, y2);
    Segment s;
    s.p1 = p1; s.p2 = p2;
    for (int i = 0; i < q; i++)
    {
        int x, y;
        cin >> x >> y;
        Point p3;
        p3.x = x; p3.y = y;
        Point p = projection(s, p3);
        cout << fixed << setprecision(10) << p.x << " " << p.y << endl;
    }
    
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endk cout<<"\n";
typedef long long int ll;
typedef long int l;
#define l(i,a,b) for(i=a;i<b;i++)
#define lo(i,a,b) for(i=a;i>=b;i--)
#define s(v) sort(v.begin(),v.end());
#define pb push_back;
#define vll vector<ll>
#define vint vector<int>
#define test() ll t;cin>>t;while(t--){solve();};
#define test1() int t=1;while(t--){solve();};
bool isPrime(ll x)
{
    ll i,n;
    n=sqrt(x);
    if(x==1) return false;
    if(x==2 || x==3) return true;
    for(i=2;i<=n;i++)
    {
        if(!(x%i)) return false;
    }
    return true;
}
ll power(ll x,ll y)
{
	ll ans=1;
	while(y>0)
	{
		if(y&1) ans=ans*x;
		x=x*x;
		y=y>>1;
	}
	return ans;
}
int solve()
{
    string s;
    int n,i;
    cin>>s;
    n=s.length();
    if(s[n-1]=='s')
    {
        s=s+"es";
    }
    else
    {
        s=s+'s';
    }
    cout<<s;
    return 0;
}
int main()
{
    fst;
    test1();
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define MAX 200000
#define INF (ll)1e10
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z


int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};

void find_way(char** map, int** way, int nx, int ny, int gx, int gy, int R, int C){
    if (nx == gx && ny == gy) return;
    if (nx+1 <= C-1) {
        if (map[ny][nx+1] != '#'){
            if (way[ny][nx+1] < 0 || way[ny][nx+1] > way[ny][nx] + 1) {
                way[ny][nx+1] = way[ny][nx] + 1;
                find_way(map, way, nx+1, ny, gx, gy, R, C);
            }
        }

    }
    if (ny+1 <= R-1) {
        if (map[ny+1][nx] != '#'){
            if (way[ny+1][nx] < 0 || way[ny+1][nx] > way[ny][nx] + 1) {
                way[ny+1][nx] = way[ny][nx] + 1;
                find_way(map, way, nx, ny+1, gx, gy, R, C);
            }
        }
    }
    if (nx-1 >= 0) {
        if (map[ny][nx-1] != '#'){
            if (way[ny][nx-1] < 0 || way[ny][nx-1] > way[ny][nx] + 1) {
                way[ny][nx-1] = way[ny][nx] + 1;
                find_way(map, way, nx-1, ny, gx, gy, R, C);
            }
        }
    }
    if (ny-1 >= 0) {
        if (map[ny-1][nx] != '#'){
            if (way[ny-1][nx] < 0 || way[ny-1][nx] > way[ny][nx] + 1) {
                way[ny-1][nx] = way[ny][nx] + 1;
                find_way(map, way, nx, ny-1, gx, gy, R, C);
            }
        }
    }
}


void solve(void){
    int h, w;
    scanf("%d%d\n", &h, &w);
    char **map = (char **)malloc(sizeof(char *) * h);
    rep(h, i){
        map[i] = (char *)malloc(sizeof(char) * (w+1));
        scanf("%s", map[i]);
    }
    int** way = (int **)malloc(sizeof(int *) * h);
    rep(h, i) {
        way[i] = (int *)malloc(sizeof(int) * w);
        rep(w, j) way[i][j] = -1;
    }
    way[0][0] = 1;
    find_way(map, way, 0, 0, h-1, w-1, h, w);
    if (way[h-1][w-1] == -1) printf("-1\n");
    else {
        int ans = 0;
        rep(h, i) rep(w, j) {
            if (map[i][j] == '.') ans++;
        }
        printf("%d\n", ans-way[h-1][w-1]);
    }
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 640