akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
bool solve() {
    ll n; cin >> n;
    vector<ll> A(n); cin >> A;
    vector<ll> cnt(n, 0);
    vector<vector<ll>> G(n);
    REP(i, n-1) {
        ll a, b; cin >> a >> b; --a, --b;
        G[a].pb(b);
        G[b].pb(a);
        cnt[a]++;
        cnt[b]++;
    }
    vector<ll> dp(n, -1);
    queue<ll> Q;
    REP(i, n) {
        if (cnt[i] <= 1) {
            Q.push(i);
        }
    }
    while ( !Q.empty() ) {
        ll v = Q.front(); Q.pop();
        ll s = 0;
        ll M = -1;
        EACH(to, G[v]) {
            if (dp[to] < 0) continue;
            s += dp[to];
            M = max(M, dp[to]);
        }
        if (G[v].size() == 1) {
            s += A[v];
            M = max(M, A[v]);
        }
        // debug(v);
        ll need = A[v]*2 - s;
        if (cnt[v] == 1) {
            if (need < 0) return false;
            dp[v] = need;
        }
        else {
            if (need != 0) return false;
        }
        M = max(M, need);
        s += need;
        if (s-M < M) return false;
        EACH(to, G[v]) {
            if (dp[to] < 0) {
                if (--cnt[to] == 1) {
                    Q.push(to);
                }
            }
        }
    }
    return true;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    if (solve()) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll n,m,d;

int main(){
    cin >> n >> m >> d;
    ll a = (n - d) * (m-1);
    if(d != 0) a *= 2.0;
    long double ans = (long double)a / (n*n);
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 3744
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            double r = double.Parse(s);
            double pi = 3.14159265358979323846;

            double area = r * r * pi;
            double ensyu = r * pi * 2;
            string area2 = string.Format("{0:f6}", area);
            string ensyu2 = string.Format("{0:f6}", ensyu);
            Console.WriteLine(area2 + " " + ensyu2);

        }
    }
}

Measured memory_bytes: 5780
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in range(n):
    if a[i] == 0:
        print(0)
        exit()
        
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 84628
#include <bits/stdc++.h>
using namespace std;
 
int main() { /* ここに書く */
  
  long long N,ans,B,Q;
  ans = 1;
  Q = 0;
  
  cin >> N ;
  
  for(int i = 0; i<N ; i++){
   
    cin >> B;
    
    if( B == 0 ){
      cout << 0 << endl;
      Q = 2;
      break;
    
    }
      

    if(ans > 1000000000000000000/B ){
     
      Q = 1;
      
    }
        
    ans = ans*B;
    
  }
  
 
  
  if( Q == 0 ){
  cout << ans << endl;
  }
  
  else if( Q == 1){
   cout << -1 << endl; 
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int R, G; cin >> R >> G;
  int B, N; cin >> B >> N;
  
  ll cnt{};
  for (int r = 0; r <= N; r += R) {
    for (int g = 0; g <= N; g += G) {
      auto b = N - (r + g);
      if (b >= 0 && b % B == 0) {
        ++cnt;
      }
    }
  }
  cout << cnt << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import sys
x = []
for line in sys.stdin:
    h,w = line.split()
    h,w = int(h), int(w)
    if h == 0 and w== 0: break
    x.append([h,w])

for i in range(len(x)):
    h, w = x[i]
    s1 = '.#' * ((w+1)/2)
    s2 = '#.' * ((w+1)/2)
    for j in range(h):
        if (j & 1)==0: print s2[:w]
        else: print s1[:w]
    print
    

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

#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 each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

bool is(string s)
{
        int cnt=0;
        each(it,s)
        {
                if(it>='A'&&it<='Z')cnt++;
        }
        if(cnt==2)return true;
        else return false;
}



main()
{
        string s; cin>>s;
        int n=s.size();
        bool f=true;
        if(s[0]!='A')f=false;
        int tmp=s.find_last_of('C');
        if(tmp==string::npos)f=false;
        if(tmp!=s.find_last_of('C'))f=false;
        if(tmp<2||tmp==n-1)f=false;
        if(is(s)==false)f=false;

        if(f)cout<<"AC"<<endl;
        else cout<<"WA"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define repll(i,n) for (ll i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll INF = 1e17;
int n;
ll K;
int P[5001];
ll C[5001];

int main() {
  INCANT;
  cin >> n >> K;
  int a;
  rep(i, n) {
    cin >> a;
    P[i] = a-1;
  }
  rep(i, n) cin >> C[i]; 
  
  ll MAX=-INF;
  rep(i, n) {
    vector<ll> score;
    ll circle=0ll;
    int p = i;
    do {
      p = P[p];
      score.push_back(C[p]);
      circle+=C[p];
    } while (p!=i);
    ll score_size = score.size();
    ll t = 0ll;
    repll(j, min(K, score_size)) {
      t+=score[j];
      ll now = t;
      if (circle>0ll) {
        ll e = (K-j-1ll)/score_size;
        now+=circle*e;
      }
      MAX=max(now, MAX);
    }
  }
  cout << MAX << endl;
  return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
//
double dp[3001][3001]; // i , heads
int32_t main()
{
    int n;
    cin >> n;
    vector<double>a(n);
    forn(i,n){
        cin >> a[i];
    }
    dp[0][0]=1;
    for(int i = 0; i < n; i++){// где я
        for(int j = 0; j <= i; j++){
            dp[i + 1][j] += dp[i][j]*(1-a[i]);
            dp[i + 1][j+1] += dp[i][j] * a[i];
        }
    }
    double ans = 0;
    for (int i = (n + 1) / 2; i <= n; i++)
        ans += dp[n][i];
    cout.precision(15);
    cout << fixed << ans << "\n";
    return 0;
}

Measured memory_bytes: 68992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, k;
    cin >> n >> k;
    k++;

    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    int64_t r = 0;
    for (int h = 1 << 30; h > 0; h >>= 1) {
        if (k & h) {
            int m = ~((k ^ h) | (h - 1));
            int64_t s = 0;
            for (int i = 0; i < n; i++) {
                if (!(a[i] & m)) s += b[i];
            }
            r = max(r, s);
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1152
a, b, c = map(int, input().split())

if a >= b and a >= c:
    if (2*a - b - c) % 2 == 0:
        print(int((2*a - b - c)/2))
    else:
        print(int((2*a - b - c)//2 + 2))
elif b >= a and b >= c:
    if (2*b -a -c) %2 == 0:
        print(int((2*b -a -c)/2))
    else:
        print(int((2*b -a -c)//2 +2))
else:
    if (2*c -b-a) % 2 ==0:
        print(int((2*c -b-a)/2))
    else:
        print(int((2*c -b-a)//2 +2))


Measured memory_bytes: 9244
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans;
	ll N,A[200010];
	ll H,W;
	char S[100][100];
	int dx[]={0,0,1,-1};
	int dy[]={1,-1,0,0};
int main(){
	ios_base::sync_with_stdio(false);
	cin>>H>>W;
	REP(i,H)REP(j,W)cin>>S[i][j];
	REP(i,H)REP(j,W){
		if(S[i][j]=='.')continue;
		bool f=true;
		REP(k,4){
			int a=dy[k]+i,b=dx[k]+j;
			if(a<0||b<0||a>=H||b>=W)continue;
			if(S[a][b]=='#')f=false;
		}
		if(f){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;

char s[1234567];
char c[1234][1234];
bool p[4][1234][1234];

int main(){
  for(int H,W,N;cin>>H>>W>>N,H|W|N;){
    fill(**begin(p),**end(p),false);
    cin>>s;
    int sy,sx;
    for(int i=0;i<H;i++){
      cin>>c[i];
      for(int j=0;j<W;j++){
	if(c[i][j]=='S'){
	  sy=i;
	  sx=j;
	}
      }
    }
    set<int> r[4];
    for(int i=0;i<4;i++){
      r[i].insert(sy*1000+sx);
      p[i][sy][sx]=true;
    }
    int d=0;
    bool f=false;
    for(int i=0;;i++){
      for(auto e:r[d]){
	int y=e/1000;
	int x=e%1000;
	for(;;){
	  static int dy[]={-1,0,1,0};
	  static int dx[]={0,1,0,-1};
	  int ny=y+dy[d];
	  int nx=x+dx[d];
	  if(ny<0||H<=ny||nx<0||W<=nx||c[ny][nx]=='#')break;
	  y=ny;
	  x=nx;
	  f|=c[y][x]=='G';
	  if(!p[d][y][x]++){
	    r[(d+1)%4].insert(y*1000+x);
	    r[(d+3)%4].insert(y*1000+x);
	  }
	}
      }
      r[d].clear();
      if(i==N)break;
      d=(d+((s[i]=='R')?1:3))%4;
    }
    cout<<(f?"Yes":"No")<<endl;
  }
}

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

using namespace std;

int jan[1010][1010] = {};
int umi[1010][1010] = {};
int koo[1010][1010] = {};

int main(){
    int64_t M, N, K;
    cin >> M >> N >> K;

    for(int i = 1; i <= M; ++i){
        for(int j = 1; j <= N; ++j){
            char c;
            cin >> c;
            if(c == 'J') ++jan[i][j];
            else if(c == 'O') ++umi[i][j];
            else ++koo[i][j];
        }
    }
    for(int i = 1; i < M; ++i){
        for(int j = 1; j <= N; ++j){
            jan[i+1][j] += jan[i][j];
            umi[i+1][j] += umi[i][j];
            koo[i+1][j] += koo[i][j];
        }
    }
    for(int i = 1; i <= M; ++i){
        for(int j = 1; j < N; ++j){
            jan[i][j+1] += jan[i][j];
            umi[i][j+1] += umi[i][j];
            koo[i][j+1] += koo[i][j];
        }
    }/*
    for(int i = 0; i <= M; ++i){
        for(int j = 0; j <= N; ++j){
            cout << jan[i][j] << " ";
        }
        cout << endl;
    }*/

    for(int i = 0; i < K; ++i){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << jan[a-1][b-1] - jan[c][b-1] - jan[a-1][d] + jan[c][d] << " ";
        cout << umi[a-1][b-1] - umi[c][b-1] - umi[a-1][d] + umi[c][d] << " ";
        cout << koo[a-1][b-1] - koo[c][b-1] - koo[a-1][d] + koo[c][d] << endl;
    }
    
}


Measured memory_bytes: 14772
import java.util.Scanner;

public class Main {
	public static void swap(int a, int b, int[] li) {
		int tmp = li[a];
		li[a] = li[b];
		li[b] = tmp;
	}

	public static int selectionSort(int[] array, int N) {
		int count = 0;
		for(int i = 0; i < N; i++) {
			boolean flag = false;
			int min = i;
			for(int j = i + 1; j < N; j++) {
				if(array[min] > array[j]) {
					min = j;
					flag = true;
				}
			}
			if(flag) {
				swap(min, i, array);
				count++;
			}
		}
		return count;
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int N = scanner.nextInt();
		int[] array = new int[N];
		for(int i = 0; i < N; i++) array[i] = scanner.nextInt();
		int count = selectionSort(array, N);
		for(int i = 0; i < N; i++) System.out.print(array[i] + (i == N - 1 ? "\n":" "));
		System.out.println(count);
		scanner.close();
	}
}


Measured memory_bytes: 26328
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<vector>
#define N 150000
#define LL long long
#define pb push_back
using namespace std;
struct node{int y,d,nex;}a[2*N];
struct node1{LL a,b;}A[N],B[N];
vector<node1> v[N];
int n,fir[N],len,f[N],du[N],al,bl;
LL ans,inf=1ll<<50,lim,g[N];
void ins(int x,int y,int d)
{
	a[++len].y=y;a[len].d=d;a[len].nex=fir[x];fir[x]=len;
}
void dfs(int x,int fa)
{
	 if(du[x]==1) {v[x].pb((node1){0,0});return;}
	 int y1=0,y2=0,s1,s2,i1,i2;LL L,mi;
	 for(int k=fir[x];k;k=a[k].nex)
	 {
		 int y=a[k].y;
		 if(y==fa) continue;
		 f[y]=a[k].d;
		 dfs(y,x);
		 if(y1==0) y1=y;
		 else y2=y;
	 }
	 s1=v[y1].size();s2=v[y2].size();
	 if(s1==0 || s2==0) return;
	 if(s1>s2) swap(s1,s2),swap(y1,y2);
	 L=lim-f[y1]-f[y2];
	 al=bl=0;
	 
	 mi=inf;i2=0;
	 for(i1=0;i1<s1;i1++)
	 {
		 while(v[y1][i1].b+mi>L && i2<s2) {mi=min(mi,v[y2][i2].a);i2++;}
		 if(v[y1][i1].b+mi>L) break;
		 A[++al]=(node1){v[y1][i1].a+f[y1],v[y2][i2-1].b+f[y2]};
	 }
	 
	 for(int i=0;i<s1;i++) g[i]=inf;
	 mi=inf;i1=0;
	 for(i2=0;i2<s2;i2++)
	 {
		 while(v[y2][i2].b+mi>L && i1<s1) {mi=min(mi,v[y1][i1].a);i1++;}
		 if(v[y2][i2].b+mi>L) break;
		 g[i1-1]=min(g[i1-1],v[y2][i2].a+f[y2]);
	 }
	 for(int i=0;i<s1;i++) if(g[i]!=inf) B[++bl]=(node1){g[i],v[y1][i].b+f[y1]};
	 
	 i1=1;i2=1;
	 while(i1<=al || i2<=bl)
	 {
		 node1 t;
		 if(i2>bl) t=A[i1++];
		 else if(i1>al || A[i1].b>B[i2].b) t=B[i2++];
		 else t=A[i1++];
		 v[x].pb(t);
	 }
}
bool check()
{
	for(int i=1;i<=n;i++) v[i].clear();
	dfs(1,0);
	if(v[1].size()) return 1;
	return 0;
}
int main()
{
	LL l=0,r=0;
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int y,d;scanf("%d%d",&y,&d);
		ins(i,y,d);ins(y,i,d);
		du[i]++;du[y]++;
		r+=d;
	}
	while(l<=r)
	{
		LL mid=(l+r)/2;
		lim=mid;
		if(check()) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 36588
#include <stdio.h>

int main() {
    long N, cnt = 0, i;
    scanf("%ld", &N);

    for (i = 1; i <= N; i++) {
        if (i % 3 == 0) {
            continue;
        }
        if (i % 5 == 0) {
            continue;
        }
        cnt += i;
    }
    printf("%ld\n", cnt);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>

using namespace std;

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


  if(a>b){
    cout << "a > b"<<endl;
  }
  else if(a==b){

    cout << "a == b"<<endl;
  }
  else{
    cout << "a < b"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int N;
    vector<int> D;
    
    cin >> N;

    for(int i = 0; i < N; i++){
        int d;
        cin >> d;

        D.push_back(d);
    }

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

    int min = 0;
    int x = 0;

    for(int i = 0; i < N; i++){
        if(min < D[i]){
            x++;
            min = D[i];
        }
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
// template version 1.8

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
const int INF=1e18;
const int MOD=1e9+7;
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int n;cin>>n;
  vector<int> a(n);
  int p=0;
  rep(i, n) {
    cin>>a[i];
    if (a[i]<0) p++;
  }
  if (p%2==0){
    int res=0;
    rep(i,n){
      res += abs(a[i]);
    }
    cout << res << endl;
  }
  else{
    int m = INF;
    int l = INF;
    rep(i, n){
      if (a[i]>=0){
        chmin(m, a[i]);
      }
      else{
        chmin(l, -a[i]);
      }
    }

    dump(m, l);
    int res=0;
    rep(i,n){
      res += abs(a[i]);
    }
    res = max(res-2*m, res-2*l);
    cout << res << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	long long int N,A,B;
  	cin>>N>>A>>B;
  	long long int count=0;
  		if( N!=0 && N>=A+B){
  			count=A*(N/(A+B));
  			N=N%(A+B);
		}
		if( N!=0 && N<A+B && N<=A){
			count=count+N;
		}
		else if( N!=0 && N<A+B && N>A){
			count=count+A;
		}
  	cout<<count<<endl;
  	return 0;
}

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

int main(void){
    int h, w;
    cin >> h >> w;
    
    char c[102];
    int i;
    for(i = 1; i <= h; i++){
        cin >> c;
        cout << c << endl;
        cout << c << endl;
    }
    
    return 0;
}


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

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define lint boost::multiprecision::cpp_int;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

template<typename t>
constexpr t mpow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}

template<typename t>
constexpr t nCr(t n,int r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(int i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

void vin(auto &a){
    for(int i=0;i<a.size();i++)cin>>a[i];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vl A(n);
    rep(i,n)cin>>A[i];
    ll res=MAXLL;
    for(int i=-100;i<=100;i++){
        ll s=0;
        rep(j,n){
            s+=mpow(A[j]-i,2);
        }
        chmin(res,s);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin>>S;

    int ans=0;
    rep(i,S.size()){
        ans+=S[i]-'0';
    }
    cout << ans << endl;






}


Measured memory_bytes: 3540
while True:
	h,w = [int(s) for s in input().split(' ')]
	if h==0 and w==0:
		break
	else:
		low = '#.' * (w//2+1)
		rectangle = ''
		for i in range(h):
			rectangle += low[i%2:i%2+w] + '\n'
		print(rectangle)

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

int main() {
	int N;
	cin >> N;
	vector<int> P(N);
	for(int i = 0; i < N; i++)
		cin >> P.at(i);

	int min = 10000000;
	int cnt = 0;
	for(int i = 0; i < N; i++) {
		if(min >= P.at(i)) {
			min = P.at(i);
			cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

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

		String[] in = sc.nextLine().split(" ");
		
		String ans = null;
		// 正直者
		if (in[0].equals("H")) {
			if (in[1].equals("H")) ans = "H";
			else ans = "D";
		}
		// 嘘つき
		else if (in[0].equals("D")) {
			if (in[1].equals("H")) ans = "D";
			else ans = "H";
		}
		
		System.out.println(ans);		
	}
}


Measured memory_bytes: 20564
//https://atcoder.jp/contests/abc117/tasks/abc117_d
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};

bool vis[64][2];
LL dp[64][2];
LL s[64];
LL t[112345][64];
int N;
LL K;

void ch(LL x,LL y[64]){
    bitset<64> b(x);
    for(int i:range(64)){
        y[i]=b[i]?1:0;
    }
}

void dfs(int n,int r){
    if(vis[n][r])return;
    vis[n][r]=true;
    LL& ret=dp[n][r];
    ret=0;
    if(n==0)return;
    n--;
    dfs(n,0);
    dfs(n,1);
    int p=1;
    if(r==0&&s[n]==0){
        p=0;
    }
    for(int i:range(p)){
        LL c=0;
        for(int j:range(N)){
            c+=(i^t[j][n])<<n;
        }
        chmax(ret,c+dp[n][1]);
    }
    for(int i:range(p,p+1)){
        LL c=0;
        for(int j:range(N)){
            c+=(i^t[j][n])<<n;
        }
        chmax(ret,c+dp[n][r]);
    }
}
int main(){
    cin>>N>>K;
    ch(K,s);
    for(int i:range(N)){
        LL a;
        cin>>a;
        ch(a,t[i]);
    }
    dfs(63,0);
    cout<<dp[63][0]<<endl;
    return 0;
}

Measured memory_bytes: 51584
#include <bits/stdc++.h>
using namespace std;
int N;
char Min='z',Max='a';char ans[200005];
void Check(char *s,int K){
	int now=N,Len=0;
	while (now>=1&&s[now]==Min) Len++,now--;
	if (!Len) exit(0);
	while (K&&Len<N) Len*=2,K--;
	if (Len>=N){
		for (int i=1;i<=N;i++)
			ans[i]=Min;
		cout<<ans+1;
		exit(0);
	}
	static char tmp[100005];
	for (int i=1;i<=Len;i++)
		tmp[i]=Min;
	for (int i=Len+1;i<=N;i++)
		tmp[i]=s[now--];
	for (int i=1;i<=N;i++){
		if (tmp[i]<ans[i]){
			for (int j=1;j<=N;j++)
				ans[j]=tmp[j];
			return;
		}
		else if (tmp[i]>ans[i]) return;
	}
}
int K;
char s[200005];
int main(){
	scanf("%d%d",&N,&K);
	cin>>s+1;
	Min='z';
	Max='a';
	for (int i=1;i<=N;i++){
		Min=min(s[i],Min);
		Max=max(s[i],Max);
		s[2*N-i+1]=s[i];
		ans[i]='z';
	}
	if (Min==Max){
		cout<<s;
		return 0;
	}
	if (s[N]==Min) Check(s,K);
	for (int i=N;i<=2*N;i++)
		if (s[i]==Min) Check(s+i-N,K-1);
	cout<<ans+1;
}

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

const int N = 1001;
const long long md = 1e9 + 7;

long long dp[N][N];


int main()
{
	int n, m;
	cin >> n >> m;
	
	vector < vector < char > > grid(n + 1, vector < char > (m + 1));
	
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			cin >> grid[i][j];
		}
	}
	
	dp[1][1] = 1;
	
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(i == 1 && j == 1)
			{
				continue;
			}
			
			if(grid[i][j] == '.')
			{
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= md;
			}
		}
	}
	
	cout << dp[n][m];
	
	return 0;
}

Measured memory_bytes: 9088
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(200000)

def dfs(idx, color, colors, conn, visited):
    visited[idx] = True
    colors[idx] = color
    for node, w in conn[idx]:
        if visited[node]:
            continue
        if w % 2 == 0:
            colors = dfs(node, color, colors, conn, visited)
        else:
            colors = dfs(node, (color + 1) % 2, colors, conn, visited)
    return colors


def solve(N: int, u: "List[int]", v: "List[int]", w: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[u[i] - 1].append([v[i] - 1, w[i]])
        conn[v[i] - 1].append([u[i] - 1, w[i]])
    colors = [-1] * N
    visited = [False] * N
    colors = dfs(0, 0, colors, conn, visited)
    #for i in range(N - 1):
    #    if w[i] % 2 == 0:
    #        if color[u[i]] >= 0 or color[w[i]] >= 0 :
    #            color[w[i]] = color[u[i]]
    #            color[u[i]] = color[w[i]]
    #    else:
    #        if color[u[i]] >= 0:
    #            color[w[i]] = (color[u[i]] + 1) % 2
    for c in colors:
        print(c)
    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
    u = [int()] * (N-1)  # type: "List[int]" 
    v = [int()] * (N-1)  # type: "List[int]" 
    w = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
        w[i] = int(next(tokens))
    solve(N, u, v, w)

if __name__ == '__main__':
    main()


Measured memory_bytes: 94752
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int ab[26]={};
  int i;
  while(getline(cin,str)){
    for(i=0;i<str.size();i++){
      if(str[i]>='a'&&str[i]<='z') ab[str[i]-'a']++;
      else if(str[i]>='A'&&str[i]<='Z') ab[str[i]-'A']++;
    }
  //cout << str << endl;
  }
  for(i=0;i<26;i++){
    cout << (char)('a'+i) << " : " << ab[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3196
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
ll f(ll x){
	ll y = 0;
	while(x){
		y += x%10;
		x /= 10;
	}
	return y;
}
int main(){
	ll x;
	cin>>x;
	cout<<(x%f(x)==0?"Yes":"No")<<endl;
	return 0;
}


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

int main()
{
    int a[50];
    int n,cnt,d[2]={};
    cnt=0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n-1;i++)if(a[i]!=i+1)cnt+=1;
    if(cnt<=2)cout<<"YES";
    else cout<<"NO";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long dp[3],a;
char op;
int n;
main()
{
	cin>>n>>dp[0];
	dp[1]=dp[2]=-1e18;
	for(int i=1;i<n;i++)
	{
		cin>>op>>a;
		if(op=='+')
		{
			for(int j=0;j<3;j++)dp[j]+=j%2?-a:a;
		}
		else
		{
			dp[2]=max(dp[2]+a,dp[1]+a);
			dp[1]=max(dp[1]+a,dp[0]-a);
			dp[0]-=a;
		}
		dp[1]=max(dp[1],dp[2]);
		dp[0]=max(dp[0],dp[1]);
	}
	cout<<dp[0]<<endl;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

A, B = MI()

tap = 1
ans = 0
for i in range(A * B) :
    if tap >= B :
        break
    
    tap += (A - 1)
    ans += 1

print(ans)


Measured memory_bytes: 43376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/



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

// テーブルを作る前処理
void C_init() {
    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 nCr(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(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    C_init();

    ll N,K;
    cin >> N >> K;

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

    sort(ALL(a));

    if(K == 1){
        cout << 0 << endl;
        return 0;
    }

    ll f_s = 0;

    for(int i = K-1;i < N;i++){//最大になりうるもの
        f_s += (nCr(i,K-1) * a[i] % MOD);
        f_s %= MOD;
        //cout << f_s << endl;
    }

    for(int i = 0;i < N-K+1;i++){//最小になりうるもの
        f_s -= (nCr(N-i-1,K-1) * a[i] % MOD);
        if(f_s < 0) f_s += MOD;
        f_s %= MOD;
        //cout << f_s << endl;
    }

    cout << f_s << endl;

}

Measured memory_bytes: 235392
import java.util.*;
class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int total = a+b+c;
        
        if(total>=22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 23380
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const S = args[0][0]
	const l = parseInt(S.slice(0, 2), 10)
	const r = parseInt(S.slice(2, 4), 10)
	let isYYMM = false 
	let isMMYY = false
	if (0 <= l && l <= 99 && 1 <= r && r <= 12) isYYMM = true
	if (1 <= l && l <= 12 && 0 <= r && r <= 99) isMMYY = true
	if (isYYMM && isMMYY) console.log('AMBIGUOUS')
	else if (isYYMM) console.log('YYMM')
	else if (isMMYY) console.log('MMYY')
	else console.log('NA')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) sort(x.begin(),x.end())
#define RALL(x) sort(x.rbegin(),x.end())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
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;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか
int ls[50], rs[50];
/*signed*/int main(void) {
    int n;
    cin >> n;
    vector<char> c(n);
    for (int i = 0; i < n; i++) cin >> c[i];
    int red_cnt = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) red_cnt += (c[i] == 'R');
    for (int i = 0; i < red_cnt; i++) ans += (c[i] != 'R');
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll X;

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; }

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

  std::cout << lcm(X,360ll)/X << std::endl;

  return 0;
}

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

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

Measured memory_bytes: 3636
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
p = tuple(map(int,readline().split()))
q = tuple(map(int,readline().split()))
if p == q:
  print(0)
  sys.exit()
l = [i+1 for i in range(N)]
count = 1
a=[]
for v in itertools.permutations(l):
  count += 1
  if v== p or v ==q:
    a.append(count)
print(a[1]-a[0])
    

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	ll x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x);
	vector<ll> b(y);
	vector<ll> c(z);
	FOR(i, 0, x-1) {
		cin >> a[i];
	}
	FOR(i, 0, y - 1) {
		cin >> b[i];
	}
	FOR(i, 0, z - 1) {
		cin >> c[i];
	}
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	int pa = SZ(a) - 1;
	int pb = SZ(b) - 1;
	int pc = SZ(c) - 1;
	priority_queue<pair<ll, tuple<int, int, int>>> que;
	set<tuple<int, int, int>> used;
	ll ten = a[pa] + b[pb] + c[pc];
	que.push(MP(ten, MT(pa, pb, pc)));
	used.insert(MT(pa, pb, pc));

	int dx[3] = { 1,0,0 };
	int dy[3] = { 0,1,0 };
	int dz[3] = { 0,0,1 };

	FOR(i, 1, k) {
		pair<ll, tuple<int, int, int>> res = que.top();
		pv(res.first);
		que.pop();
		FOR(j,0,2){
			pa = get<0>(res.S) - dx[j];
			pb = get<1>(res.S) - dy[j];
			pc = get<2>(res.S) - dz[j];
			if (pa >= 0 && pb >= 0 && pc >= 0 && used.find(MT(pa, pb, pc)) == used.end()) {
				ll ten = a[pa] + b[pb] + c[pc];
				/*dump(ten);
				dump(pa);
				dump(pb);
				dump(pc);
				cout << endl;*/
				que.push(MP(ten, MT(pa, pb, pc)));
				used.insert(MT(pa, pb, pc));
			}
		}
	}
	return 0;
}

Measured memory_bytes: 896
let n, x = Scanf.scanf "%d %d\n" (fun n x -> (n, x))

let a =
  Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x))
  |> Array.to_list

let rec solve pre count = function
  | [] -> count
  | h :: t ->
    let y = if pre + h > x then (pre + h - x) else 0 in
    solve (h - y) (count + y) t

let () = Printf.printf "%d\n" (solve 0 0 a)

Measured memory_bytes: 6400
import java.util.Scanner;

// https://atcoder.jp/contests/abc156/tasks/abc156_c
public class Main {

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}
		sc.close();

		int ans = 99*99*100;
		for(int i=1;i<=101;i++) {
			int sum = 0;
			for(int j=0;j<n;j++) {
				sum = sum + (array[j]-i)*(array[j]-i);
			}
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double x=0;
    for(int i=0;i<n;++i)
    {
        double a;
        cin>>a;
        x += 1/a;
    }
    printf("%.6f\n",1/x);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_up_int_l(const void *a, const void *b){
   return *(long int*)a - *(long int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int compare_down_int_l(const void *a, const void *b){
   return *(long int*)b - *(long int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,count=0;
  scanf("%d",&N);
  long int num[N];
  for(int i=0;i<N;i++) scanf("%ld ",&num[i]);
  for(int i=0;i<N;i++){
    while(1){
      if(num[i]%2==0){
        count++;num[i]/=2;
      }
      else break;
    }
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 256