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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextInt();
        ArrayList<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextLong());
        }
        list.add(x);
        Collections.sort(list);
        ArrayList<Long> list2 = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list2.add(list.get(i + 1) - list.get(i));
        }
        long ans = list2.get(0);
        for (int i = 1; i < n; i++) {
            ans = gcd(ans, list2.get(i));
        }
        System.out.println(ans);
    }

    public static final long gcd(long a, long b) {
        if( b == 0 ) return a;
        return gcd(b, a % b);
    }
}

Measured memory_bytes: 62028
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 
class dsu{
    public:
    unordered_map<int,int> p,sz;
    void make_set(int x)
    {
        p[x] = x;
        sz[x]+=1;
    }
    int find(int x)
    {
        if(x == p[x])return x;
        return p[x] = find(p[x]);
    }
    void merge(int a,int b)
    {
        a = find(a);
        b = find(b);
        if(a == b)return;
        if(sz[a]<sz[b])swap(a,b);
        p[b] = a;
        sz[a]+=sz[b];
        sz.erase(b);
    }
};
template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = (res*a);
        b>>=1;
        a*=a;
    }
    return res;
}
class wemen{
public:
    int b,i,r;
    wemen(){

    }
    bool operator<(const wemen& o){
        if(b!=o.b)return b>o.b;
        else if(i!=o.i)return i>o.i;
        else return r>=o.r;
    }
};
void online_judge(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int kmp(string s){
    vector<int> lps(s.size(),0);
    for(int i = 1; i<lps.size(); ++i){
        int prev_index = lps[i-1];
        while(prev_index>0&&s[i]!=s[prev_index]){
            prev_index = lps[prev_index-1];
        }
        lps[i] = prev_index+(s[i] == s[prev_index]?1:0);
    }
    return lps[lps.size()-1];
}
int ask1(int node){
    cout<<1<<' '<<node<<endl;
    int ans;
    cin>>ans;
    return ans;
}
int ask2(int node,int y){
    cout<<2<<' '<<node<<' '<<y<<endl;
    int ans;
    cin>>ans;
    return ans;

}
int main()
{
    fastio();
   int k,n;
   cin>>k>>n;
   vector<int> a(n);
   fori(i,0,n)cin>>a[i];
   int ans = a[n-1]-a[0];
   for(int i = 1;i<n; i++){
    ans = min(ans,k-(a[i]-a[i-1]));
   }
   cout<<ans<<"\n";
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i <= (int)(b); i++)
#define RFOR(i, a, b) for (int i = a; i >= (int)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[ ";
    for (auto a : v) os << a << " ";
    os << "]";
    return os;
}

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    REP(i, N) cin >> p[i];

    vector<bool> num(102);
    REP(i, N) num[p[i]] = true;

    REP(i, 101) {
        int l = max(X - i, 0);
        int r = min(X + i, 101);
        if (!num[l]) {
            cout << l << endl;
            break;
        } else if (!num[r]) {
            cout << r << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
n = gets.to_i
m = Array.new(10).map{Array.new(10,0)}

for i in (1..n)
  m[i.to_s[0].to_i][i.to_s[-1].to_i] += 1
end
sum = 0
for i in (0..9)
  for j in (0..9)
    sum += m[i][j] * m[j][i]
  end
end
puts sum


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

int ch1(int a,int b){
    if(a>b)swap(a,b);
    int s=sqrt(a*b-1);
    if(s==0)return 0;
    int mx=(a*b-1)/s;
    if(mx<s)swap(s,mx);
    int ans=2*s,f=0;
    if(mx==s)ans--;
    if(a<=s)ans--;
    if(mx==b&&s*(mx+1)>=a*b){
      ans--;
    }
    return ans;
}

int ch2(int a,int b){
  long long root = sqrt(a*b);
  long long ans = root + (a*b-1)/root-1;
  if ((a*b-1)/root >= a) ans --;
  if ((a*b-1)/root >= b) ans --;
  return ans;
}

signed main(){
  int q,a,b;
  cin>>q;
  while(q--){
    cin>>a>>b;
    cout<<ch1(a,b)<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        R: usize, C: usize, K: usize,
        yxv: [(usize, usize, i64); K],
    }

    let mut items = vec![vec![0; C+1]; R+1];
    for (y, x, v) in yxv {
        items[y][x] = v;
    }

    let mut dp = vec![vec![0; C+1]; 5];
    for y in 1..R+1 {
        for x in 1..C+1 {
            let mut from_above = 0;
            for i in 0..=3 {
                from_above = max(from_above, dp[i][x]);
            }
            dp[0][x] = max(dp[0][x], from_above);
            dp[1][x] = max(dp[1][x], from_above + items[y][x]);
            for k in 0..=3 {
                let from_left = dp[k][x-1];
                dp[k][x] = max(dp[k][x], from_left);
                dp[k+1][x] = max(dp[k+1][x], from_left + items[y][x]);
            }
            dp[4][x] = 0;
        }
    }
    let mut ans = 0;
    for i in 0..=3 {
        ans = max(ans, dp[i][C]);
    }
    println!("{}", ans);

}


Measured memory_bytes: 80672
from collections import deque
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
count = [0]*N
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(Q):
    p, x = map(int, input().split())
    count[p-1]+=x
q = deque([0])
flag = [False]*N
while q:
    v = q.pop()
    flag[v] = True
    for e in G[v]:
        if flag[e]:
            continue
        count[e]+=count[v]
        q.append(e)
print(*count)

Measured memory_bytes: 56084
#include <iostream>
using namespace std;
#define condFOR(i, cond) for (int i = 0; (cond); ++i)

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  A *= 100; B *= 100;
  int w = 1, s = -1;
  condFOR(w_a, A*w_a <= F) {
    condFOR(w_b, A*w_a + B*w_b <= F) {
      if ( w_a + w_b == 0 ) continue;
      int new_w = A*w_a + B*w_b, new_s = 0;
      int G = min(new_w*E/100, F-new_w);
      condFOR(s_c, C*s_c <= G) {
        condFOR(s_d, C*s_c + D*s_d <= G) {
          int temp = C*s_c + D*s_d;
          if ( new_s > temp ) continue;
          new_s = temp;
          if ( new_s*w > s*new_w ) {
            w = new_w, s = new_s;
          }
        }
      }
    }
  }
  cout << w+s << ' ' << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long ans, a[8];
int main()
{
    for(int i = 1;i < 8; ++ i)cin >> a[i];
    if(a[1] && a[4] && a[5]){
        ans = 3;
        ans += ((a[1] - 1) / 2) * 2 + ((a[4] - 1) / 2) * 2 + ((a[5] - 1) / 2) * 2;
    }
    ans = max(ans, (a[1] / 2) * 2 + (a[4] / 2) * 2 + (a[5] / 2) * 2);
    ans += a[2];
    cout << ans;
    return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<LL> v(N);
    REP(i, N) {
        cin >> v[i];
    }
    LL x = v[0];
    LL y = 0;
    FOR(i, 1, N) {
        y += v[i];
    }
    LL res = abs(x - y);
    FOR(i, 1, N - 1) {
        x += v[i];
        y -= v[i];
        res = min(abs(x - y), res);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define PMAX 100000
bool prime[PMAX];
void primefy(){
  for(int i=0; i < PMAX; i++){
    prime[i] = true;
  }
  prime[0] = false;
  prime[1] = false;
  for(int i=2; i < sqrt(PMAX); i++){
    if(prime[i]){
      for(int j=i+i; j < PMAX; j+=i){
	prime[j] = false;
      }
    }
  }
}



int main(void){
  primefy();
  vector<int> prime_list;
  int cnt = 0;
  for(int i=0; i < PMAX; i++){
    if(prime[i]){
      prime_list.push_back(i);
      cnt++;
    }
  }
  
  int m, a, b;
  while(cin >> m >> a >> b, m | a | b){
    int p_max, q_max;
    p_max = q_max = 0;
    for(int i=0; i < cnt; i++){
      if(prime_list[i]*2 > m) break;
      for(int j=i; j < cnt; j++){
	if(prime_list[j]*2 > m) break;
	if(prime_list[i] * prime_list[j] <= m && 
	   a / (double)b <= prime_list[i] / (double)prime_list[j] &&
	   prime_list[i] / (double)prime_list[j] <= 1.0 &&
	   prime_list[i]*prime_list[j] > p_max * q_max){
	  p_max = prime_list[i];
	  q_max = prime_list[j];
	}
      }
    }
    cout << p_max << " " << q_max << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1420
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX = 1e6;
const int INF = 2e9;
typedef long long ll;

const int DIV = 998244353;
int n, s;
int a[3001];
int dp[3001][3001];

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

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

    for (int i = 1; i <= n; ++i)
    {
        dp[i][a[i]] = i;
        for (int j = 1; j <= s; ++j)
        {
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % DIV;
            if (j - a[i] > 0) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % DIV;
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        ans = (ans + dp[i][s]) % DIV;
    }

    cout << ans % DIV;

    return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vector<int> G[1010];
int x[1010];
int dfs(int now,int p){
	int dp[2][5010];
	for(int i=0;i<=x[now];i++){
		dp[0][i]=INF;dp[1][i]=INF;
	}
	int cu=1;int to=0;
	dp[cu][0]=0;
	for(auto e:G[now]){
		if(e==p)continue;
		for(int i=0;i<=x[now];i++)dp[to][i]=INF;
		int w=dfs(e,now);
		int b=x[e];
		for(int i=0;i<=x[now];i++){
			if(dp[cu][i]!=INF){
				if(i+w<=x[now]){
					dp[to][i+w]=min(dp[to][i+w],dp[cu][i]+b);
				}
				if(i+b<=x[now]){
					dp[to][i+b]=min(dp[to][i+b],dp[cu][i]+w);
				}
			}
		}
		cu=(cu+1)%2;
		to=(to+1)%2;
	}	
	int res=INF;
	for(int i=0;i<=x[now];i++){
		res=min(res,dp[cu][i]);
	}	
	return res;
}
int main(){
	int n;cin>>n;
	for(int i=1;i<n;i++){
		int p;cin>>p;p--;
		G[p].push_back(i);
	}
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	if(dfs(0,-1)==INF){
		cout<<"IMPOSSIBLE"<<endl;
	}else{
		cout<<"POSSIBLE"<<endl;
	}
	return 0;
}


Measured memory_bytes: 14592
from collections import deque

H, W = map(int, input().split())
A = [input() for _ in range(H)]

check = [[-1 for _ in range(W)] for _ in range(H)]
q = deque()
for i in range(H):
  for j in range(W):
    if  A[i][j] == "#":
      check[i][j] = 0
      q.append((i, j))

while q:
  i, j = q.popleft()
  
  if i - 1 >= 0 and check[i - 1][j] == -1:
      check[i - 1][j] = check[i][j] + 1
      q.append((i - 1, j))

  if i + 1 < H and check[i + 1][j] == -1:
      check[i + 1][j] = check[i][j] + 1
      q.append((i + 1, j))

  if j - 1 >= 0 and check[i][j - 1] == -1:
      check[i][j - 1] = check[i][j] + 1
      q.append((i, j - 1))

  if j + 1 < W and check[i][j + 1] == -1:
      check[i][j + 1] = check[i][j] + 1
      q.append((i, j + 1))

answer = -1
for i in range(H):
  answer = max(answer, max(check[i]))
print(answer)

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

vector<vector<pii>> adj;
vector<int64> useEdge;

bool dfs(int32 idx, int32 v, int32 g, int32 p = -1){
  if(v == g)return true;
  for(auto u : adj[v]){
    if(u.first == p)continue;
    if(dfs(idx,u.first,g,v)){
      useEdge[idx] |= (1ll << u.second);
      return true;
    }
  }
  return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  adj.resize(n);
  REP(i,n-1){
    int32 a,b;
    cin >> a >> b;
    --a;--b;
    adj[a].emplace_back(b,i);
    adj[b].emplace_back(a,i);
  }
  int32 m;
  cin >> m;
  useEdge.resize(m,0);
  REP(i,m){
    int32 u,v;
    cin >> u >> v;
    --u;--v;
    dfs(i,u,v);
  }
  // REP(i,n)cout << depth[i] << endl;
  int64 ans = 0;
  for(int32 mask = 0; mask < (1 << m); ++mask){
    int32 cnt = 0;
    int64 uesum = 0;
    REP(i,m){
      if((mask>>i)&1){
        cnt++;
        uesum |= useEdge[i];
      }
    }
    // cout << cnt << " " << st.size() << endl;
    if(cnt%2)ans -= (1ll << (n-1-__builtin_popcountll(uesum)));
    else ans += (1ll << (n-1-__builtin_popcountll(uesum)));
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()

    val l1 = (1..n).map { sc.next() to sc.nextInt() }.toList()
    val l2 = l1.sortedByDescending { it.second }.sortedBy { it.first }.toList()
    l2.map { l1.indexOf(it) + 1 }.forEach(::println)
}


Measured memory_bytes: 34096
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;
using ll = long long;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

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

  int mn = 754;
  for(int i=0; i<n-2; ++i){
    string str = s.substr(i,3);
    int num = stoi(str);
    int res = abs(num-753);
    mn = min(mn, res);
  }
  cout << mn;
}  


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
long double calcCircleOf2Point(long double x1, long double  y1, long double  x2, long double  y2, long double  x3, long double  y3, long double  *cx, long double  *cy, long double  *r)
{
	long double 	ox, oy, a, b, c, d ;
	long double	r1, r2, r3 ;
	ll		stat ;

	a = x2 - x1 ;
	b = y2 - y1 ;
	c = x3 - x1 ;
	d = y3 - y1 ;

	stat = -1 ;

	if  ((a && d) || (b && c)) {
		ox = x1 + (d * (a * a + b * b) - b * (c * c + d * d)) / (a * d - b * c) / 2 ;
		if  (b) {
			oy = (a * (x1 + x2 - ox - ox) + b * (y1 + y2)) / b / 2 ;
		} else {
			oy = (c * (x1 + x3 - ox - ox) + d * (y1 + y3)) / d / 2 ;
		}
		r1   = sqrt((ox - x1) * (ox - x1) + (oy - y1) * (oy - y1)) ;
		r2   = sqrt((ox - x2) * (ox - x2) + (oy - y2) * (oy - y2)) ;
		r3   = sqrt((ox - x3) * (ox - x3) + (oy - y3) * (oy - y3)) ;
		*cx = ox ;
		*cy = oy ;
		*r  = (r1 + r2 + r3) / 3 ;
		stat = 0 ;
	}

	return stat ;
}

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

  ll n;
  cin >> n;
  long double x[n],y[n];
  
  rep(i,n) cin >> x[i] >> y[i];
  long double eps = 5e-7;
  long double ans = 1e6;
  long double ma=0;

  rep(i,n)rep(j,n){
    if(i>=j)continue;
    bool ok=true;
    long double cx = (x[i]+x[j])/2.;
    long double cy = (y[i]+y[j])/2.;
    long double hankei = sqrt((cx-x[j])*(cx-x[j]) + (cy-y[j])*(cy-y[j]));
    rep(k,n){
      long double dist = sqrt((cx-x[k])*(cx-x[k])+(cy-y[k])*(cy-y[k]));
      if(dist-hankei > eps){
        ok = false;
        break;
      }
    }
    if(ok){
      ans = hankei;
      break;
    }
    ma = max(hankei,ma);
  }
    rep(i,n)rep(j,n)rep(l,n){
      bool ok=true;
    long double cx;
    long double cy;
    long double r;
    int st = calcCircleOf2Point(x[i],y[i],x[j],y[j],x[l],y[l],&cx,&cy,&r);
    if(st==-1) continue;
    long double hankei = sqrt((cx-x[j])*(cx-x[j]) + (cy-y[j])*(cy-y[j]));
    rep(k,n){
      long double dist = sqrt((cx-x[k])*(cx-x[k])+(cy-y[k])*(cy-y[k]));
      if(dist-hankei > eps){
        ok = false;
        break;
      }
    }
    if(ok){
      ans = min(ans,hankei);
      break;
    }



  }
  //  if(ans>1e5) ans = ma;
  cout <<fixed << setprecision(12) <<  ans << endl;

 
  return 0;
    

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	float a,b,c,d,e,f,x,x1,X,y;
	while((scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f))!=EOF){
		x=0; x1=0;
		y=0; X=0;
		x=d*b-a*e;
		x1=d*c-a*f;
		y=x1/x;
		X=(c-(b*y))/a;
		printf("%0.3f %0.3f\n",X,y);
	}
	return 0;
}

Measured memory_bytes: 648
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	int n;
	int ans = 0;
	cin >> n;
	int a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		ans += b - a + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {


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

        int[] nums = new int[N];
        for (int i = 0; i < N; i++) nums[i]=sc.nextInt();

        //sort
        Arrays.sort(nums);

        StringBuilder sb = new StringBuilder();
        // + Max  - min  and middle |abs|
        int max =nums[nums.length-1];
        int min =nums[0];
        int ans = min;
        for (int i = 1; i <= nums.length-2 ; i++) {// minus all positive except max
            if(nums[i]>=0){
                sb.append(ans+" "+nums[i]+"\n");
                ans = ans - nums[i];
            }
        }
        sb.append(max+" "+ans+"\n");
        ans = max - ans;
        for (int i = 1; i <= nums.length-2 ; i++) {// minus all positive except max
            if(nums[i]<0){
                sb.append(ans+" "+nums[i]+"\n");
                ans = ans - nums[i];
            }
        }

        System.out.println(ans);
        System.out.println(sb.toString());
    }

}


Measured memory_bytes: 66468
import std.stdio,std.string,std.conv,std.math;

double memo[1001][2];

void calc()
{
	memo[0][0] = 1;
	memo[0][1] = 0;
	double angle = 0;

	foreach(i;1..1001)
	{
		double r = sqrt(1.0+i);
		angle += asin(1.0/r);
		memo[i][0] = r * cos(angle);
		memo[i][1] = r * sin(angle);
	}
}

int main()
{
	int n;
	calc();
	while((n = readln.chomp.to!int) != -1)
	{
		writefln("%.2f",memo[n-1][0]);
		writefln("%.2f",memo[n-1][1]);
	}

	return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>
int main(void){
    int a,b,c,d;
    
        
        
    //    scanf
        scanf("%d%d%d",&a,&b,&c);


        if(a < b){
            printf("%d\n",c);
            
// 剰余の処理
        }else{
            if (a % b == 0) {
                d = a / b;
            }else{
                d = a / b + 1;
            }

            
            printf("%d\n",c * d);
            }
            
    return 0;
}


Measured memory_bytes: 1700
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		
		long[] arr=new long[n];
		for(int i=0;i<n;i++)
			arr[i]=s.nextLong();
		long[][] dp=new long[n][n];
		for(int i=0;i<n;i++) {
			dp[i][i]=0;
		}
		long[] pre=new long[n];
		pre[0]=arr[0];
		for(int i=1;i<n;i++)
			pre[i]=pre[i-1]+arr[i];
		for(int len=2;len<=n;len++) {
			int i=0;
			int j=i+len-1;
			while(i<n && j<n) {
			if(len==2) {
				dp[i][j]=arr[i]+arr[j];
			}
			else {
				long best=Long.MAX_VALUE;
				for(int k=i;k<j;k++) {
					long cand=dp[i][k]+dp[k+1][j]+((i==0)?pre[j]:pre[j]-pre[i-1]);
					best=Math.min(best, cand);
				}
				dp[i][j]=best;
			}
			i++;
			j++;
			}
		}
		
		System.out.println(dp[0][n-1]);
	}
	
	
	
}


Measured memory_bytes: 24684
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = null;

        try {
            sc = new Scanner(System.in);
            int countRectangle = 0;
            int countRhombus = 0;

            while (sc.hasNextLine()) {
                String[] input = sc.nextLine().split(",");
                int[] sides = convertToInt(input);

                if (isRectangle(sides)) {
                    countRectangle++;
                } else if (isRhombus(sides)) {
                    countRhombus++;
                }
            }

            System.out.println(countRectangle);
            System.out.println(countRhombus);

        } finally {
            sc.close();
        }
    }

    public static boolean isRectangle(int[] side) {
        return square(side[0]) + square(side[1]) == square(side[2]);
    }

    public static boolean isRhombus(int[] side) {
        return side[0] == side[1];
    }

    public static int square(int n) {

        return n * n;
    }

    public static int[] convertToInt(String[] strings) {
        int[] ints = new int[3];

        for (int i = 0; i < ints.length; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        return ints;
    }

}

Measured memory_bytes: 25824
#include <stdio.h>

int main()
{
    int n, i, j;
    int mem=0, ans=0;
    scanf("%d", &n);

    int a[n], b[n];
    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    for(i=0; i<n; i++)
    {
        scanf("%d", &b[i]);
    }

    j = n-1;
    while(0 <= j)
    {
        for(i=0; i<n; i++)
        {
            if(i < j)
            {
                mem += a[i];
            }
            else
            {
                mem += b[i];
            }
        }
        mem += a[j];
        if(mem > ans)
        {
            ans = mem;
        }
        mem = 0;
        j--;
    }

    printf("%d\n", ans);

    return 0;

}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;;
	cin >>n >>m;
	VL a(n);
	rep(i, n) cin >>a[i];
	sort(a.rbegin(), a.rend());
	ll sm = accumulate(all(a), 0LL);

	rep(i, m){
		if(a[i] * 4 * m < sm){
			puts("No"); return 0;
		}
	}
	
	
	puts("Yes");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

const int MAX = 2000010;
// const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll K;string S;
    cin>>K>>S;
    ll N = S.size();
    vector<ll> vec(K+10,0);

    COMinit();
    ll ten = 1; 
    rep(i,K+1) {
        vec[i] = (ten*COM(N-1+i,N-1))%MOD;
        ten = (ten*25)%MOD;
    }
    vector<ll> vec2(K+10,0);
    vec2[0] = vec[0];
    rep(i,K) {
        vec2[i+1] = (vec[i+1] + 26*vec2[i]%MOD) % MOD;
    }
    cout<<vec2[K]<<endl;
}

Measured memory_bytes: 66816
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  std::vector<ll> a(n),value,count;
  rep(i,0,n)std::cin>>a[i];

  std::sort(all(a));

  ll prev=a[0],cnt=1;

  value.push_back(a[0]);

  rep(i,1,n){
    if(a[i]!=prev){
      value.push_back(a[i]);
      count.push_back(cnt);
      cnt=1;
      prev=a[i];
    }else{
      cnt++;
    }
  }

  count.push_back(cnt);

  ll size=value.size(),ans=0;

  for(ll i=size-1;i>=0;i--){
    ll pow=1;
    while(value[i]>=pow)pow*=2;

    ll itr=std::lower_bound(all(value),pow-value[i])-value.begin();

    while(count[i]>0){
      count[i]--;
      if((value[itr]==pow-value[i])&&count[itr]>0){
        ans++;
        count[itr]--;
      }
    }
  }

  std::cout<<ans;

  return 0;
}


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

int	main()
{
	string	s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 998244353;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  if(v[0]!=0){
    cout<<0<<endl;
    return 0;
  }
  sort(ALL(v));
  ll stock=v[n-1];
  ll ans=1;
  map<ll,ll> mp;
  rep(i,n) mp[v[i]]++;
  if(mp[0]>=2){
    cout<<0<<endl;
    return 0;
  }
  ll tmp=mp[1];
  for(ll i=2;i<=stock;i++){
    rep(j,mp[i]){
      ans*=tmp;
      ans%=MOD;
    }
    tmp=mp[i];
    if(ans==0){
      cout<<0<<endl;
      return 0;
    }
  }
  
  cout<<ans%MOD<<endl;
}

Measured memory_bytes: 7296
args = int(input())

ans = float('inf')
for i in range(args+1):
    count = 0

    args_six = i
    while args_six >= 6:
        count += args_six % 6
        args_six //= 6
    count += args_six

    args_nine = args - i
    while args_nine >= 9:
        count += args_nine % 9
        args_nine //= 9
    count += args_nine
    ans = min(ans, count)

print(ans)

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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    for (int i = 0; i < 10; i++)
    {
        cout << a*c - b << endl;
        c = a*c - b; 
    }
}


Measured memory_bytes: 256
import java.awt.Point;
import java.util.LinkedList;
import java.util.Scanner;
 
public class Main {
     
	static int W, H;
	static int[][] s;
	static int[] c;
	
    static void start()
    {
    	int[][][] cost = new int[H][W][4];
    	Boolean[][][] check = new Boolean[H][W][4];
    	
    	for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				for (int d = 0; d < 4; d++) {
					cost[y][x][d] = Integer.MAX_VALUE;
					check[y][x][d] = false;
				}
			}
		}
    	cost[0][0][0] = 0;
    	
    	int[] dx = {1, 0, -1,  0};
    	int[] dy = {0, 1,  0, -1};
    	
    	while(true)
    	{
    		int cx = 0, cy = 0, cd = 0;
    		
    		// 次のcx, cy, cdを探す
    		int min = Integer.MAX_VALUE;
    		for (int y = 0; y < H; y++) {
    			for (int x = 0; x < W; x++) {
    				for (int d = 0; d < 4; d++) {
    					if(check[y][x][d] == true) continue;
    					
    					if(cost[y][x][d] < min)
    					{
    						min = cost[y][x][d];
    						cy = y;
    						cx = x;
    						cd = d;
    					}
    				}
    			}
    		}
    		if(min == Integer.MAX_VALUE) break;
    		
    		check[cy][cx][cd] = true;
    		for (int i = 0; i < 4; i++) {
				int nd = (cd + i) % 4;
				int nx = cx + dx[nd];
				int ny = cy + dy[nd];
				
				if ( !( 0<=nx && nx <= W-1) ) continue;
				if ( !( 0<=ny && ny <= H-1) ) continue;
				if( check[ny][nx][nd] == true ) continue;
				
				if(s[cy][cx] == i)
					cost[ny][nx][nd] = Math.min(cost[ny][nx][nd], cost[cy][cx][cd]);
				else {
					cost[ny][nx][nd] = Math.min(cost[ny][nx][nd], cost[cy][cx][cd] + c[i]);
				}
			}
    	}
    	
    	System.out.println(Math.min(cost[H-1][W-1][0], cost[H-1][W-1][1]));
    	
//    	System.out.println("-- cost ----------------------------------------------------");
//    	
//    	for (int y = 0; y < H; y++) {
//			for (int x = 0; x < W; x++) {
//				for (int d = 0; d < 4; d++) {
//					System.out.println("cost[" + y + "][" + x + "][" + d + "] = " + cost[y][x][d]);
//					System.out.println("check[" + y + "][" + x + "][" + d + "] = " + check[y][x][d]);
//				}
//			}
//		}
//    	
//    	System.out.println("----------------------------------------------------------");
    }
     
    public static void main(String[] args)
    {
        Scanner sca = new Scanner(System.in);
        
        while(true)
        {
        	W = sca.nextInt();
        	H = sca.nextInt();
        	if(W == 0) break;
        	
        	s = new int[H][W];
        	for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					s[y][x] = sca.nextInt();
				}
			}
        	
        	c = new int[4];
        	for (int i = 0; i < 4; i++) {
				c[i] = sca.nextInt();
			}
            
            start();
        }
        
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(2e5) + 5;
const int MAX_A = int(15e6);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll mod_power(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n&1) res = res*a%MOD;
        a = a*a%MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    ll m, n;
    cin >> m >> n;
    cout << mod_power(m,n) << endl;
    return 0;
}



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

class Program
{
    static void Main(string[] args)
    {
        int[] nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int total = 0;
        int n = nm[0];
        int m = nm[1];
        foreach (int aa in a)
        {
            total += aa;
        }
        if (total <= n)
            Console.WriteLine(n - total);
        else
            Console.WriteLine(-1);
    }
}

Measured memory_bytes: 28992
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)
		    r=(r*a)%m;
		b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
    ll n,m; cin>>n>>m;
    vi arr(n);
    rep(i,0,n)cin>>arr[i];
    ll temp = 0;
    rep(i,0,n)
    {
        ll z = 0;
        while(arr[i]%2==0)
        {
            arr[i]/=2;
            ++z;
        }
        if(!i)temp = z;
        else
        {
            if(z!=temp)
            {
                cout<<0<<endl;
                return 0;
            }
        }
    }

    ll g = arr[0]*pow(2,temp-1);
    rep(i,1,n)
    {
        arr[i]*=pow(2,temp-1);
        g = (g*arr[i])/__gcd(g,arr[i]);
    }

    cout<<(m+g)/(2*g)<<endl;
    return 0;

}


Measured memory_bytes: 1152
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
const int MOD(1e9 + 7);
int freq[62][2], n, curr, res;
long long x, p2[62];
int main() {
    DAU
    p2[0] = 1;
    for (int i = 1; i < 62; ++i)
        p2[i] = p2[i - 1] << 1;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        for (int bit = 0; bit < 62; ++bit)
            ++freq[bit][!!(x & p2[bit])];
    }
    for (int bit = 0; bit < 62; ++bit)
        res = (res + (1LL * ((1LL * freq[bit][0] * freq[bit][1]) % MOD) * (p2[bit] % MOD)) % MOD) % MOD;
    cout << res;
    PLEC
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;

int main() {
 int N;
 cin>>N;
 vector<string>u(N);
 vector<double>x(N);
 double ans=0;
 for(int i=0;i<N;i++){
     cin>>x[i]>>u[i];
     if(u[i]=="JPY"){ans+=x[i];}
     else{ans+=x[i]*380000;}
 }
 cout<<fixed<<setprecision(6);
 cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
cin >> N;
bool flag = true;
vector<string>W(N);
for(int i = 0; i < N; i++){ 
       cin >> W.at(i);
      }


for(int i = 0; i < N - 1; i++){ 
       if(W.at(i).back() != W.at(i + 1).front()){
             flag = false;
             break;
       }
}
// if(flag) cout << "Yes" << endl; 
// else cout << "No" << endl; 

if(flag){
      for(int i = 0; i < N; i++){ 
            for(int j = i + 1; j < N; j++){ 
                  if(W.at(i) == W.at(j)) {
                        flag = false;
                        break;
                  }
            }
      }
}

if(flag) cout << "Yes" << endl; 
else cout << "No" << endl; 


}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::i64;
use std::io::{stdin, Read};
use std::usize;

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let s = it.next().unwrap();
    if s.chars().last().unwrap() == 's' {
        println!("{}es", s);
    } else {
        println!("{}s", s);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, cnt = 0;
  cin >> N >> K;
  int A[N+1] = {0};
  
  for(int i = 0; i < K; i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int a;
      cin >> a;
      A[a] = 1;
    }
  }
  for(int i = 1; i < N+1; i++) if(A[i] == 0) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

string s;
bool a, b, c, d;

int main () {
        cin >> s;
        for (char x : s) {
                if (x == 'N') a = 1;
                if (x == 'S') b = 1;
                if (x == 'E') c = 1;
                if (x == 'W') d = 1;
        }
        if (0 + a + b == 1 || 0 + c + d == 1) puts("No");
        else puts("Yes");
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,l,cnt=0;
    string s;
    cin>>s;
    l=s.size();
    for(i=0; i<l; i++)
    {
        for(j=0; j<l; j++)
        {
            if(s[i]==s[j])
            {
                n++;
            }
        }
        if(n%2==0)
        {
            cnt++;
        }
        else
        {
            break;
        }
    }
    if(cnt==l)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


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

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

    vector<bool> paintCans(100, false);
    paintCans.at(a-1) = true;
    paintCans.at(b-1) = true;
    paintCans.at(c-1) = true;

    int kindsNum(0);
    for(int i(0); i < paintCans.size(); i += 1) {
        if(paintCans.at(i)) kindsNum += 1;
        if(kindsNum == 3) break;
    }

    cout << kindsNum << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    x = int(input())
    for i in range(1000):
        for j in range(0, i+1):
            y = i ** 5 - j ** 5
            z = i ** 5 + j ** 5
            if x == y:
                a = i
                b = j
                break
            elif x == z:
                a = i
                b = -j
                break
    print(a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
N,M = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(M)]
l.sort(key=lambda x: x[1])
broken_bridge = 0
position = 0
for i in range(M):
    if position<l[i][0]:
        broken_bridge+=1
        position = l[i][1]-1
print(broken_bridge)


Measured memory_bytes: 28448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");
		String h = "No";

		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);
		int c = Integer.parseInt(cut[2]);

		if (a + b == c || a + c == b || b + c == a) {
			h = "Yes";
		}

		System.out.println(h);
	}
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
inline void read(int &x)
{
    char c=getchar();x=0;int f=1;
    while(c>'9'||c<'0') {if(c=='-') f=-1;c=getchar();}
    while(c<='9'&&c>='0') x=(x<<1)+(x<<3)+c-'0',c=getchar();
    x=x*f;
}
int n,x,maxx;
struct node
{
    int x,v;
}ji[110000],ou[110000];
inline bool cmp(node a,node b)
{
    return a.v>b.v;
}
int main()
{
    read(n);
    for(int i=1;i<=n;i++)
    {
        read(x);
        if(i%2==1) ji[x].v++;
        else ou[x].v++;
        maxx=max(maxx,x);
    }
    for(int i=1;i<=maxx;i++)
    {
        ji[i].x=ou[i].x=i;
    }
    sort(ji+1,ji+1+maxx,cmp);
    sort(ou+1,ou+1+maxx,cmp);
    if(ji[1].x!=ou[1].x)
    {
        printf("%d",n-ji[1].v-ou[1].v);
    }
    else
    {
        printf("%d",n-max(ji[2].v+ou[1].v,ji[1].v+ou[2].v));
    }
    
    #ifdef _WIN32
    system("pause");
    #endif
}

Measured memory_bytes: 1792
/*
Anki:未済
作成日:
*/

#include <stdio.h>

int main()
{
    long a, b, h;
    int area;

    scanf( "%ld\n%ld\n%ld", &a, &b, &h );

    area = (a + b) * h / 2;
    printf( "%d\n", area );

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;
} 

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

int main() {
  string A;
  cin>>A;
  
    if (A=="SUN")
      cout<<7<<endl;
    else if (A=="MON")
      cout<<6<<endl;
      
    else if (A=="TUE")
      cout<<5<<endl;
     
    else if (A=="WED")
      cout<<4<<endl;
    else if (A=="THU")
      cout<<3<<endl;
     
    else if (A=="FRI")
      cout<<2<<endl;
      
   else 
      cout<<1<<endl;
      
  
  return 0;
}
     


Measured memory_bytes: 3580
#include <iostream>
using namespace std;
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int counter = 0;
  for(int i=1; i<=n; i++){
    int num = i;
    int sum = 0;
    while(num!=0){
      sum += (num % 10);
      num /= 10;
    }
    if(a <= sum && sum <= b){
      counter += i;
    }
  }
  cout << counter;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

inline void gc(int* x){
    *x = 0;
    for(;;){
        int c=getchar_unlocked();
        if('0'<= c && c <='9'){
            *x = *x*10 + c-'0';
        }else{
            break;
        }
    }
}

int main(void){
    using namespace std;
    constexpr int KMAX = 1000;
    static int s[KMAX+1][2*KMAX+1];
    char c;
    int n, k, x, y;
    scanf("%d %d\n", &n, &k);
    for(int i=0; i<n; i++){
        gc(&x);
        gc(&y);
        c=getchar_unlocked();
        getchar_unlocked();
        y %= 2*k;
        if(c=='W'){
            if(y>=k){
                y-=k;
            }else{
                x+=k;
            }
        }else{
            if(y>=k){
                y-=k;
                x+=k;
            }
        }
        x %= 2*k;
        s[y+1][x+1]++;
    }
    for(int y=0; y<k; y++){
        for(int x=0; x<2*k; x++){
            s[y+1][x+1] += s[y][x+1] + s[y+1][x] - s[y][x];
        }
    }
    int max = 0;
    int v = s[0][0] - s[0][2*k];
    for(int y=0; y<k; y++){
        int u = v - s[y][0] + s[y][2*k];
        for(int x=0; x<k; x++){
            int t = u - s[0][x] - s[k][x] + s[0][x+k] + s[k][x+k] + 2*s[y][x] - 2*s[y][x+k];
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    printf("%d", max);
    return 0;
}



Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	int n;
	cin>>n;
	vector<string>s(n);
	int ac=0,re=0,wa=0,tle=0;
	
	
	for(int i=0;i<n;i++){cin>>s[i];
	    if(s[i]=="TLE"){tle++;}
	    else if(s[i]=="WA")wa++;
	    else if(s[i]=="AC")ac++;
	    else{
	        re++;
	    }
	}
	
	cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
	
	
	
	return 0; 
	}

Measured memory_bytes: 6344
#!/usr/bin/env python3
import sys


def solve(r: int):
    print(r**2)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    solve(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940