akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n;
  cin >> n;
  int a = n % 10;
  if (a == 3)
    cout << "bon\n";
  else if (a == 0 || a == 1 || a == 6 || a == 8)
    cout << "pon\n";
  else
    cout << "hon\n";
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void dfs(Graph &G, vector<ll> &it, vector<ll> &ans, int now, int pre, ll plus) {
    ans[now] += it[now] + plus;
    for(auto &v: G[now]) {
        if (v == pre){
            continue;
        }else{
            dfs(G, it, ans, v, now, ans[now]);
        }
    }
}

void Main() {
    int N, Q;
    cin >> N >> Q;
    Graph G(N);
    vector<ll> pp(N, 0);
    rep(i, Q) {
        pp[i] = 0;
    }
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, Q) {
        int p, x;
        cin >> p >> x;
        pp[p-1] += x;
    }
    vector<ll> ans(N, 0);
    dfs(G, pp, ans, 0, -1, 0);
    rep(i, N) {
        cout << ans[i] << " ";
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 32128
A, B = map(int, input().split())


def f(a):
    if a % 2 == 0:
        return 0^a if (a // 2) % 2 == 0 else 1^a
    else:
        return 0 if ((a+1) // 2) % 2 == 0 else 1

print(f(B)^f(A-1))



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

using namespace std;

int main() {
  
  int N;
  while(cin >> N && N) {
    for(int i=0; i<N; i++) {
      double a, b, c;
      cin >> a >> b >> c;
      string r;
      if(a == 100.0 || b == 100.0 || c == 100.0) r = "A";
      else if((a+b)/2 >= 90.0) r = "A";
      else if((a+b+c)/3 >= 80.0) r = "A";
      else if((a+b+c)/3 >= 70.0) r = "B";
      else if((a+b+c)/3 >= 50.0 && (a >= 80.0 || b >= 80.0)) r = "B";
      else r = "C";
      cout << r << endl;
    }
  }
  
  return 0;
}

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

using namespace std;

typedef pair<int, int> P;

int main() {
  int N, T;
  cin >> N >> T;
  vector<P> D(N);
  for (int i = 0; i < N; ++i) cin >> D[i].first >> D[i].second;
  sort(D.begin(), D.end());
  string res("TLE");
  for (int i = 0; i < N; ++i) {
    if (D[i].second <= T) {
      res = to_string(D[i].first);
      break;
    }
  }
  cout << res << endl;
}

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

int main(){
	string S;
	cin >> S;
	vector<int> count(3,0);
	for(int i=0;i<S.size();i++)count[S[i]-'a']++;
	sort(count.begin(),count.end());
	if(count[2]-count[0]<=1)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main()
{
    string s; cin >> s;

    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
count = 0
tmp = 0
while(1):
	tmp_2=0
	if tmp == 1:
		break
	for i in range (N):
		if A[i]%2 == 1:
			print(count)
			tmp = 1
			break
		else:
			tmp_2 += 1
	if tmp_2 == N:
		count += 1
		for i in range (N):
			A[i] = A[i]/2
		

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

int main(){
  string S;
  cin >> S;
  
  vector<string> week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  
  for(int i = 0; i < week.size(); i++) {
    if(S == week.at(i)) {
      cout << week.size() - i << endl;
    }
  }
}

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

int main(){
  int D,score=0;
  cin >> D;
  vector<int> C(26);
  for(int i=0;i<26;i++){
    cin >> C.at(i);
  }
  vector<vector<int>> S(D,vector<int>(26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin >> S.at(i).at(j);
    }
  }
  vector<int> T(D);
  for(int i=0;i<D;i++){
    cin >> T.at(i);
  }
  vector<int> memo(26);
  for(int i=1;i<=D;i++){
    score+=S.at(i-1).at(T.at(i-1)-1);
    memo.at(T.at(i-1)-1)=i;
    for(int j=1;j<=26;j++){
      score-=C.at(j-1)*(i-memo.at(j-1));
    }
    cout << score << endl;
  }
}

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

namespace lean
{
    class Program
    {
        static void Main()
        {
            string[] a = Console.ReadLine().Split();
            Console.WriteLine(a[2] +" "+ a[0] + " "+ a[1]);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int main(void){
   int r,c,i,j;
   scanf("%d %d",&r,&c);
   int a[100+1][100+1];
   if(r<1||100<r||c<1||100<c) return 1;
   for(i=0;i<=r;i++){
       for(j=0;j<=c;j++){
           a[i][j]=0;
       }
   }
   for(i=0;i<r;i++){
       for(j=0;j<c;j++){
           scanf("%d",&a[i][j]);
       }
   }
   for(i=0;i<r;i++){
       for(j=0;j<c;j++){
           a[i][c]+=a[i][j];
       }
   }
   for(j=0;j<c;j++){
       for(i=0;i<r;i++){
           a[r][j]+=a[i][j],a[r][c]+=a[i][j];
       }
   }
   for(i=0;i<=r;i++){
       for(j=0;j<=c;j++){
           printf("%d",a[i][j]);
           if(j!=c) putchar(' ');
       }
       putchar('\n');
   }
   return 0;
}


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

int main()
{
	int X, Y;

	cin >> X;
	cin >> Y;

	int rest = Y;

	while (X % Y != 0) {
		rest = X % Y;
		X = Y;
		Y = rest;
	}

	cout << rest << endl;

    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int flag=1;
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
            if((a[i]%3==0)||(a[i]%5==0))
                flag=1;
            else
            {
                flag=0;
                break;
            }
        }
    }
    if(flag==0)
    cout<<"DENIED";
    else
    cout<<"APPROVED";
}

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

int main() {
   int n;
   cin >> n;
   int p[30];
   rep(i,n)
   cin >> p[i];
   int l,r,ans=0;
   for(int i=1;i<n-1;i++){
      l=min({p[i-1],p[i],p[i+1]}),r=max({p[i-1],p[i],p[i+1]});
      if(l!=p[i]&&r!=p[i])
      ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 100000+10;

int n,m;
vector<int> g[maxn];
int d[maxn],fa[maxn];

void bfs(int S)
{
    queue<int> que;
    que.push(S);
    memset(d,-1,sizeof(d));
    d[S]=0;
    while (!que.empty())
    {
        int x=que.front();
        que.pop();
        for (int i=0;i<g[x].size();i++)
        {
            int q=g[x][i];
            if (d[q]==-1)
            {
                d[q]=d[x]+1;
                fa[q]=x;
                que.push(q);
            }
        }
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    bfs(1);
    bool jud=1;
    for (int i=2;i<=n;i++)
    {
        if (fa[i]==0) jud=0;
    }
    if (jud)
    {
        printf("Yes\n");
        for (int i=2;i<=n;i++) printf("%d\n",fa[i]);
    } else printf("No\n");
    return 0;
}


Measured memory_bytes: 10996
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int count = 0;
    int v;
    for(int i = 0; i < n - 1; i++) {
      for(int j = n - 1; j > i; j--) {
        if(a[j - 1] > a[j]) {
          v = a[j];
          a[j] = a[j - 1];
          a[j - 1] = v;
          count++;
        }
      }
    }
    for(int i = 0; i < n; i++) {
      if(i == n - 1) {
        System.out.println(a[i]);
      } else {
        System.out.print(a[i] + " ");
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 26324
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <math.h>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int mod=256;
	while(1){
		int n; cin >> n;
		if(n==0)break;
		vector<int> x(n);
		for(int i=0;i<n;i++){
			cin >> x[i];
		}
		double h=1e9;
		int s,a,c;
		for(int i=0;i<16;i++){
			for(int j=0;j<16;j++){
				for(int k=0;k<16;k++){
					int cnt[256]={};
					int r=i;
					for(int l=0;l<n;l++){
						r=(j*r+k)%mod;
						cnt[(x[l]+r)%mod]++;
					}
					double cul=0;
					for(int l=0;l<256;l++){
						if(cnt[l]){
							double t=1.0*cnt[l]/n;
							cul-=t*log2(t);
						}
					}
					if(cul<h){
						h=cul;
						s=i,a=j,c=k;
					}
				}
			}
		}
		cout << s << " " << a << " " << c << endl;
	}
}


Measured memory_bytes: 3340
n,m=map(int,input().split())
def dfs(now,depth):#現在見ている点、今まで列挙した頂点数
    if used[now]:
        return 0
    if depth==n:
        return 1
    used[now]=1#使用済みグラフを立てる
    ans=0#出力値を数える変数
    for i in range(n):#全部の遷移先を調べる
        if connect[now][i]:#nowから繋がっている頂点であれば遷移を試す。
            ans+=dfs(i,depth+1)
    used[now]=0#使用済みグラフを折る
    return ans
edge=[[int(i)for i in input().split()]for i in range(m)]#入力値受け取り、グラフの初期設定
connect=[[0 for i in range(n)]for i in range(n)]#接続状況を管理する配列
for i in range(m):
    connect[edge[i][0]-1][edge[i][1]-1]=1
    connect[edge[i][1]-1][edge[i][0]-1]=1
used=[0]*n#既にその頂点を訪問したか管理する配列
print(dfs(0,1))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define forx(v) for(int x=0; x<v; x++)
#define ll long long
#define lll __int128
#define MAX (int)(4*pow(10,5) + 100)
#define pb(a) push_back(a)
#define ch (int)(4*pow(10,4) + 100)
#define ld long double
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = 998244353;
double eps = 1e-9;
ifstream in;
ofstream out;

 
void deal(){
	ll n;
	cin>>n;
	map<ll, ll> dp;
	map<ll, ll> reach;
	
	reach[inf] = inf;
	dp[inf] = 1;
	
	vector<pair<ll,ll> > all(n);
	fori(n){
		cin>>all[i].ff>>all[i].ss;
	}
	sort(all.begin(), all.end());
	
	
	ll pv = 1;
	for(ll i = all.size()-1; i>-1; i--){
		ll xi = all[i].ff, di = all[i].ss;
		ll mx = xi+di-1;
		auto it = reach.upper_bound(all[i].ff+all[i].ss-1);
		if(it != reach.begin()){
			--it;
			mx = max(mx, (*it).ss);
		}
		reach[xi] = mx;
		{
	//		cout<<"we in "<<endl;
			it = reach.find(xi);
			auto it1 = it;
			++it1;
			while((*it1).ss <= (*it).ss){
				reach.erase(it1);
				it1 = it;
				++it1;
			}	
	//		cout<<"we out "<<endl;
		}
		
		it = dp.upper_bound(reach[xi]);
		pv+=(*it).ss;
		pv%=modulo;
		dp[xi] = pv;
	}
	
	cout<<dp[all[0].ff];
	
}
 
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
 
 
/* 
6 8 
1 2
2 3
3 4
4 1
2 5
3 5
1 6
4 6
*/

Measured memory_bytes: 22144
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;

	int win(string a,string b){//aが勝てば0,bが勝てば1,引き分けなら2
		int flag=-1;
		for(int i=0;i<min(a.size(),b.size());i++){
			if(a[i]==b[i])continue;
			if(a[i]-'a'>b[i]-'a')return 0;
			else if(a[i]-'a'<b[i]-'a')return 1;
		}
		if(a.size()==b.size())return 2;
		else if(a.size()!=b.size()){
			if(a.size()>b.size())return 0;
			else return 1;
		}
	}
int main(){
	string a,b;//aが太郎bが花子
	int n;
	int t=0,h=0;
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>a>>b;
		if(win(a,b)==0)t+=3;
		else if(win(a,b)==1)h+=3;
		else if(win(a,b)==2){t+=1;h+=1;}
	}
	printf("%d %d\n",t,h);
return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    cin >> b[i];
    a[i]-=b[i];
  }
  sort(a.begin(),a.end());
  vector<bool> c(n,false);
  int ans=0,t=0;
  while(a[t]<0){
    if(a[a.size()-1] <= 0){
      puts("-1");
      return 0;
    }else {
      int tmp = min(-a[t],a[a.size()-1]);
      a[t]+=tmp;
      a[a.size()-1]-=tmp;
      c[t]=true;
      c[a.size()-1]=true;
    }
    if(a[t] == 0) t++;
    if(a[a.size()-1] == 0) a.pop_back();
  }
  for(int i=0;i<n;i++)ans+=c[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	private static Scanner sc;

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

		int[] L = new int[N];

		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}

		int now = 0;
		int ans = 1;

		for (int i = 0; i < N; i++) {
			now += L[i];
			if (now > X) {
				break;
			}
			ans++;
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 21972
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1e5 + 20;
long long n;
long long a[MAXN], pos[MAXN];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for(int i = 1; i <= n; i++) {
    	cin >> a[i];
    	pos[a[i]] = i;
    }
    long long l = min(pos[n], pos[n - 1]), r = max(pos[n], pos[n - 1]);
    set<long long > st({0, l, r, n + 1});
    long long res = (n - 1) * (n - r + 1) * l;
    //cout << res << endl;
    for(int i = n - 2; i >= 1; i--) {
    	st.insert(pos[i]);
    	auto it1 = st.find(pos[i]);
    	it1--;
    	auto it2 = it1;
    	if(it2 != st.begin()) it2--;
    	auto it3 = st.find(pos[i]);
    	it3++;
    	auto it4 = it3;
    	it4++;
    	if(it4 == st.end()) it4--;

    	res += (*it3 - pos[i]) * (*it1 - *it2) * i;
    	res += (pos[i] - *it1) * (*it4 - *it3) * i;
    }
    cout << res << endl;


    return 0;
}











Measured memory_bytes: 6528
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

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

	st s;
	cin >> s;
	stack<char> a, b;
	LL ans = 0;
	f(i, 0, size(s)) {
		a.push(s[i]);
	}
	while (!a.empty()) {
		char x = a.top();
		a.pop();
		if ((!a.empty()) && x != a.top()) {
			ans += 2;
			a.pop();
			continue;
		}
		if ((!b.empty()) && x != b.top()) {
			ans += 2;
			b.pop();
			continue;
		}
		b.push(x);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
def digSum(num):
    ret = 0
    for c in num:
        ret += int(c)
    return ret

n = int(input())
ans = 10000
for i in range(1, n):
    a = str(i)
    b = str(n - i)
    ans = min(ans, digSum(a) + digSum(b))

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      int a1,a2,a3,a4;
      a1=N/1000;
      a2=(N%1000)/100;
      a3=((N%1000)%100)/10;
      a4=((N%1000)%100)%10;
     
      if (a1 != a2 && a3 != a4) {
        cout << "No" << endl;
      }
      else if(a2 == a3){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
          
    }

Measured memory_bytes: 3652
#include<stdio.h>
#define N 100

int main(){
  int n, m, a[N][N], sum, sum2, i, j;

  scanf("%d%d",&n,&m);

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

  for(i=0;i<n;i++){
    sum=0;
    for(j=0;j<m;j++){
      printf("%d ",a[i][j]);
      sum+=a[i][j];
    }
    printf("%d\n",sum);
  }
  
  sum2=0;
  for(i=0;i<m;i++){
    sum=0;
    for(j=0;j<n;j++){
      sum+=a[j][i];
      sum2+=a[j][i];
    }
    printf("%d ",sum);
  }
  printf("%d\n",sum2);
  
  return 0;
}



Measured memory_bytes: 2068
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char c[10];
    scanf("%s",c);
    int cou=0;
    int max=0;
    for(int i=0;i<strlen(c);i++){
        if(c[i]=='A' ||c[i]=='T' ||c[i]=='G' ||c[i]=='C' ){
            cou++;
        }else{
            if(cou>max)max=cou;
            cou=0;
        }
    }
    if(cou>max)max=cou;
    printf("%d\n",max);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void)
{
	int t;
	cin >> t;
	int h = t / 3600;
	t -= 3600 * h;
	int m = t / 60;
	int s = t - 60 * m;
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int H = 2e4 + 7;
const int INF = 1e9 + 239;

int dp[H];

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

    int w, n;
    cin >> w >> n;
    vector<pair<int, int>> sp(n);
    for (auto &t : sp) {
    	cin >> t.first >> t.second;
    }
   	fill(dp, dp + H, INF);
   	dp[0] = 0;
   	for (int i = 0; i < H; i++) {
   		for (auto t : sp) {
   			if (i + t.first < H) {
   				dp[i + t.first] = min(dp[i + t.first], dp[i] + t.second);
   			}
   		}
   	}
   	int ans = INF;
   	for (int i = w; i < H; i++) {
   		ans = min(ans, dp[i]);
   	}
   	cout << ans << endl;
}   


Measured memory_bytes: 384
def search(a, s):
    min_i = 0
    max_i = len(a)-1
    i = int(len(a)/2)

    if a[min_i] < s and s < a[max_i]:
        while True:
            if a[i] <= s and s < a[i+1]:
                break
            elif s < a[i]:
                max_i = i
                i = min_i + int((max_i - min_i)/2)
            else:
                min_i = i
                i = min_i + int((max_i - min_i)/2)

        return i
    elif s <= a[min_i]:
        return min_i
    else:
        return max_i

N,M,K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_SUM = [0]
B_SUM = [0]

for i in range(N):
    A_SUM.append(A[i] + A_SUM[i])

for j in range(M):
    B_SUM.append(B[j] + B_SUM[j])

count = 0
for i in range(N+1):
    if K >= A_SUM[i]:
        a = K - A_SUM[i]
        j = search(B_SUM, a)
        if count < i + j:
            count = i + j

print(count)


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


// グローバル変数
int A[100];
int top;

void initialize() {
  top = 0;
}

int pop() {
  top--;
  return A[top+1];
}

void push(int s) {
  top++;
  A[top] = s;
}


int main() {
  char s;
  initialize();
  while (scanf("%s", &s) != EOF) {
    if (s == '+' || s == '-' || s == '*') {
      int b = pop();
      int a = pop();
      if (s=='+') push(a+b);
      else if (s=='-') push(a-b);
      else if (s=='*') push(a*b);
    } else push(atoi(&s));
  }
  printf("%d\n", pop());
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string> 

using namespace std;
typedef long long ll;
int main(int argc, char const *argv[])
{
    int n;cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++)cin>>d[i];
    sort(d.begin(),d.end());
    int b = d[n/2-1];
    int e = d[n/2];
    int ret =0;
    if(b!=e)ret = e-b;
    cout<<ret<<endl;
    return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vec h(n);
    init(h);
    sort(all(h), greater<int>());
    int res = INF;
    For(i, k - 1, n - 1) res = min(res, h[i - k + 1] - h[i]);

    print(res);
    return 0;
}

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

using namespace std;
typedef unsigned int UINT;
typedef int INT;


int main()
{
	int total = 0;
	int a, b, n;
	cin >> n >> a >> b;

	for (int val = 1; val <= n; ++val) {
		int sum = 0;
		{
			int tmp = val;
			int div;

			div = tmp / 10000;
			sum += div;
			tmp = tmp - 10000 * div;

			div = tmp / 1000;
			sum += div;
			tmp = tmp - 1000 * div;

			div = tmp / 100;
			sum += div;
			tmp = tmp - 100 * div;

			div = tmp / 10;
			sum += div;
			tmp = tmp - 10 * div;

			sum += tmp;
		}

		if (sum >= a && sum <= b) { total += val; }
	}
	cout << total << endl;
	return 0;
}




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

int main()
{
    long long int n,f=1,i;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
        f=f*i;
    if(n==0)
           printf("0\n");
    else
           printf("%lld\n",f);
    return 0;
}

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

int main(){
	int n,a,b,c,d,r1,r2;
	cin >> n ;
	a  = n /1000;
	r1 = n %1000;
	b  = r1/ 100;
	r2 = r1% 100;
	c  = r2/  10;
	d  = r2%  10;
	char op1, op2, op3;
	if (a+b+c+d==7){
		op1 = '+';
		op2 = '+';
		op3 = '+';
	} else if (a+b+c-d==7){
		op1 = '+';
		op2 = '+';
		op3 = '-';
	} else if (a+b-c+d==7){
		op1 = '+';
		op2 = '-';
		op3 = '+';
	} else if (a+b-c-d==7){
		op1 = '+';
		op2 = '-';
		op3 = '-';
	} else if (a-b+c+d==7){
		op1 = '-';
		op2 = '+';
		op3 = '+';
	} else if (a-b+c-d==7){
		op1 = '-';
		op2 = '+';
		op3 = '-';
	} else if (a-b-c+d==7){
		op1 = '-';
		op2 = '-';
		op3 = '+';
	} else if (a-b-c-d==7){
		op1 = '-';
		op2 = '-';
		op3 = '-';
	}
	cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a,b) ((a)<(b)?(a):(b))

int desc(const void *a, const void *b) {
   long long *A = (long long *)a;
   long long *B = (long long *)b;
   if (*A < *B) {
      return 1;
   } else if (*A > *B) {
      return -1;
   } else {
      return 0;
   }
}

int main(void) {
   long long int X,Y,Z,K;
   scanf("%lld %lld %lld %lld", &X, &Y, &Z, &K);
   long long int *A = (long long int *)malloc(X * sizeof(long long int));
   long long int *B = (long long int *)malloc(Y * sizeof(long long int));
   long long int *C = (long long int *)malloc(Z * sizeof(long long int));
   long long int *L = (long long int *)malloc((X*Y+1) * sizeof(long long int));
   for (long long int i = 0; i < X; i++) {
      scanf("%lld", &A[i]);
   }
   for (long long int i = 0; i < Y; i++) {
      scanf("%lld", &B[i]);
   }
   for (long long int i = 0; i < Z; i++) {
      scanf("%lld", &C[i]);
   }
   for (long long int i = 0; i < X; i++) {
      for (long long int j = 0; j < Y; j++) {
         L[i*Y+j] = A[i] + B[j];
      }
   }
   free(A);free(B);
   long long int *M = (long long int *)malloc(Z*3001 * sizeof(long long int));
   qsort(L,X * Y,sizeof (long  int), desc);
   for (long long int i = 0; i < 3001; i++) {
      for (long long int j = 0; j < Z; j++) {
         M[i*Z+j] = L[i] + C[j];
      }
   }
   qsort(M,MIN(3000*Z,X*Y*Z),sizeof (long long int), desc);
   for (long long int i = 0; i < K; i++) {
      printf("%lld\n",M[i]);
   }
   return 0;
}



Measured memory_bytes: 54920
#include <iostream>
using namespace std;
int main() {
	int in;
	int h, m, s;
	cin >> in;

	h = in / 3600;
	in %= 3600;

	m = in / 60;
	in %= 60;

	s = in;

	cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1168
#include<stdio.h>
#include<math.h>
int main(void)
{
  int i,j,n,p,count=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&p);
      if(p == 2 || p==3){count++;}

      else if(p%2 != 0 && p>4)
	{
      for(j=3;j<sqrt((double)p);j+=2)
	  {
	  if(p%j == 0){break;}
	  } 
      if(p%j){count++;}
	}
    }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.next();
        String s2 = scanner.next();
        if(s1.length() > s2.length()){
            System.out.println("GREATER");
        }
        else if(s1.length() < s2.length()){
            System.out.println("LESS");
        }
        else{
            for (int i = 0;i < s1.length();++i){
                if((int) s1.charAt(i) > (int) s2.charAt(i)){
                    System.out.println("GREATER");
                    break;
                }
                else if((int) s1.charAt(i) < (int) s2.charAt(i)){
                    System.out.println("LESS");
                    break;
                }
                else if(i + 1 == s1.length()){
                    System.out.println("EQUAL");
                }
            }
        }
    }
}

Measured memory_bytes: 21844
import java.util.*;


 
public class Main {

    public static void main(String args[])  {
    	Scanner sc = new Scanner(System.in);
    	double shortA=sc.nextInt();
    	double longB =sc.nextInt();
    	double time=sc.nextInt();
    	double minute=sc.nextInt();
    	double all=360;
    	double ans=0.0;
        double timeMinute=60.0*time+minute;
        double shortaa=(timeMinute/720.0)*360;
        double longaa =minute*6;
        double angle=0.0;
        if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } 

  
        if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        }
     
        double cos = Math.cos(Math.toRadians(angle));
         ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos);

  
        System.out.println(ans);


    }
}

Measured memory_bytes: 35968
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */

public class Main {

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

        char[][] ans = new char[4][N];

        ans[0][0] = 'S';
        ans[0][1] = 'S';
        ans[1][0] = 'W';
        ans[1][1] = 'W';
        ans[2][0] = 'S';
        ans[2][1] = 'W';
        ans[3][0] = 'W';
        ans[3][1] = 'S';

        int flag = -1;
        for (int i = 0; i < 4; i++) {
            for (int j = 2; j < N; j++) {
                if(s.charAt(j - 1) == 'o'){
                    if(ans[i][j - 1] == 'S'){
                        ans[i][j] = ans[i][j - 2];
                    }else{
                        ans[i][j] = rev(ans[i][j - 2]);
                    }
                }else{
                    if(ans[i][j - 1] == 'W'){
                        ans[i][j] = ans[i][j - 2];
                    }else{
                        ans[i][j] = rev(ans[i][j - 2]);
                    }

                }
            }
            Boolean a = check(s.charAt(N - 1), ans[i][N - 1], ans[i][N - 2], ans[i][0]);
            Boolean b = check(s.charAt(0), ans[i][0], ans[i][N - 1], ans[i][1]);
            if(a && b){
                flag = i;
                break;
            }

        }


        if(flag == -1){
            System.out.println(-1);
        }else{
            for (int i = 0; i < N; i++) {
                System.out.print(ans[flag][i]);
            }
            System.out.println();
        }


    } // mainMethod

    public static char rev(char c){
        if(c == 'S'){
            return 'W';
        }else{
            return 'S';
        }
    }

    public static Boolean check(char say, char ani, char kind1, char kind2){
        if(say == 'o'){
            if(ani == 'S'){
                return kind1 == kind2;
            }else{
                return kind1 != kind2;
            }

        }else{
            if(ani == 'S'){
                return kind1 != kind2;
            }else{
                return kind1 == kind2;
            }

        }

    }


} // MainClass


Measured memory_bytes: 39532
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  vector<int> num(3);
  rep(i, 3) cin >> num[i];
  sort(num.begin(), num.end());
  cout << num[0]+num[1]+(num[2]*10) <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>

using namespace std;


int main()
{
  map<int,bool> exist;
  int a,b;
  cin >> a >> b;
  vector<int> A,B;
  vector<vector<int> > men;
  men.resize(2);
  men[0].resize(b),men[1].resize(b);
  A.resize(a),B.resize(b);
  for(int i=0;i<a;i++)
    cin >> A[i];
  for(int i=0;i<b;i++)
    cin >> B[i],men[0][i] = men[1][i] = 0,exist[B[i]] = true;

  

  int mex = 0;
  for(int i=0;i<a;i++)
    {
      if(!exist[A[i]])
	continue;
     
      for(int j=0;j<b;j++)
	{
	  if(A[i] == B[j])
	    {
	      men[1][j] = max(men[0][j],j-1>=0?men[0][j-1]+1:0);
	      if(!men[1][j])
		men[1][j] = 1;
	      mex = max(men[1][j],mex);
	    }
	}
     
      men[0] = men[1];
    }
 
  cout << mex << endl;
  return 0;
}

Measured memory_bytes: 1340
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
 
 
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
const int INF = 100000000;
const double EPS = 0.0000001;
typedef pair<int,int> P;

int n,m,p;


int calc0(int A,int C,double D,int Y) {
	int B;
	int sumB=0;
	rep(i,Y) {
		B = A*D;
		sumB += B;
		A-=C;
	}

	return sumB+A;
}

int calc1(int A,int C,double D,int Y) {
	int B;
	rep(i,Y) {
		B=A*D;
		A=A+B-C;
	}
	return A;
}
void solve() {
	//初期のお金
	int s;cin>>s;
	//年数,しゅるい
	cin>>m>>p;
	
	int maxi = 0;

	rep(i,p) {
		int a,c;
		double b;
		cin>>a>>b>>c;

		rep(i,m) {
			//単利
			if(a==0) {
				maxi=max(maxi,calc0(s,c,b,m));
			}
			else {
				
				maxi=max(maxi,calc1(s,c,b,m));
			}
		}
	}

	cout<<maxi<<endl;
}

int main() {

	cin>>n;
	rep(i,n) solve();

	return 0;
}

Measured memory_bytes: 1232
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

using namespace std;

typedef unsigned long long LL;

int n, k, ans;
int a[223456];

int main() {

   
    cin >> k >> n;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }

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

    ans = max(ans, k-a[n]+a[1]);

    ans = k - ans;
    cout << ans << endl;
    

}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>


int main() {

  int N;
  scanf("%d", &N);

  int* A = (int*)malloc(sizeof(int) * N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }

  for (int i = 0; i < N; i++) {
    int v = A[i], j;
    for (j = i - 1; j >= 0 && A[j] > v; j--) {
      A[j + 1] = A[j];
    }
    A[j + 1] = v;

    for (int k = 0; k < N; k++) {
      if (k) printf(" ");
      printf("%d", A[k]);
    }
    printf("\n");
  }

  return 0;
}


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

using namespace std;

bool check(int i, int a, int b)
{
    int res = 0;
    while(i) {
        res += i % 10;
        i /= 10;
    }

    return a <= res && res <= b;
}

int main()
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);

    int ans = 0;
    for(int i = 1; i <= n; i++)
        if(check(i, a, b))
            ans += i;
    printf("%d\n", ans);

    return 0;
}


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

int main() {
  while(1) {
    string s="",t,r;
    getline(cin,s);
    if(s=="") break;
    while(1) {
      getline(cin,r);
      if(r=="") break;
      s+=r;
    }
    getline(cin,t);
    getline(cin,r);
    
    map<char,int> m,d;
    m.clear();
    d.clear();
    for(int i=0; i<t.size(); i++) d[t[i]]=1;
    vector<int> v;
    for(int i=0; i<s.size(); i++) {
      if(d[s[i]]==1) v.push_back(i);
    }
    int x=0,cnt=0;
    string ans=s;
    for(int i=0; i<v.size(); i++) {
      char c=s[v[i]];
      m[c]++;
      if(m.size()==t.size()) {
	while(m[s[v[x]]]>1) {
	  m[s[v[x]]]--;
	  x++;
	}
	if(ans.size()==v[i]-v[x]+1) {
	  cnt++;
	} else if(ans.size()>v[i]-v[x]+1) {
	  cnt=1;
	  ans=s.substr(v[x],v[i]-v[x]+1);
	}
      }
    }
    
    if(cnt==0) cout << cnt << endl;
    else {
      cout << cnt << endl << endl;
      for(int i=0; i<ans.size(); i++) {
	cout << ans[i];
	if((i+1)%72==0) cout << endl;
      }
      if(ans.size()%72) cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2116
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
d = list(itertools.permutations(range(1, n + 1)))
d.sort()

a = -1
b = -1
for i in range(len(d)):
    if d[i] == p:
        a = i
    if d[i] == q:
        b = i
print(abs(a - b))

Measured memory_bytes: 79916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		string[] t = Input();
		int n = int.Parse(t[0]);
		int m = int.Parse(t[1]);
		t = Input();
		HeapQueue<long> a = new HeapQueue<long>(n);
		//int[] b = new int[n];
		
		for(int i = 0; i < n; i++)
		{
			a.Push(long.Parse(t[i]));
		}
		//Array.Sort(a);
		//Array.Reverse(a);
		for(int j = 0; j < m;j++ )
		{
			long va = a.Pop();
			va = va >> 1;
			a.Push(va);
		}
		long v = 0;
		for(int i = 0; i < n; i++)
		{
			v += a.Pop();
		}
		Console.WriteLine(v);
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}

class HeapQueue<T> where T : IComparable<T>
{
	private List<T> _buffer;
	
	public HeapQueue()
	{
		_buffer = new List<T>();
	}
	
	public HeapQueue(int capacity)
	{
		_buffer = new List<T>(capacity);
	}
	
	public void Push(T el)
	{
		PushHeap(_buffer, el);
	}
	
	public T Pop()
	{
		T el = _buffer[0];
		PopHeap(_buffer);
		return el;
	}
	
	public int Count
	{
		get{ return _buffer.Count; }
	}
	
	private static void PushHeap(List<T> array, T elem)
    {
      int n = array.Count;
      array.Add(elem);

      while (n != 0)
      {
        int i = (n - 1) / 2;
        if (array[n].CompareTo(array[i]) > 0)
        {
          T tmp = array[n]; array[n] = array[i]; array[i] = tmp;
        }
        n = i;
      }
    }
    
    private static void PopHeap(List<T> array)
    {
      int n = array.Count - 1;
      array[0] = array[n];
      array.RemoveAt(n);

      for (int i = 0, j; (j = 2 * i + 1) < n; )
      {
        if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) < 0))
          j++;
        if (array[i].CompareTo(array[j]) < 0)
        {
          T tmp = array[j]; array[j] = array[i]; array[i] = tmp;
        }
        i = j;
      }
    }
    
}



Measured memory_bytes: 25564
#include<bits/stdc++.h>
using namespace std;
#define P pair<int, int>
int n, m, wh, ans, dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
char s[55][55];
queue<pair<P, int> > qu;

int main(){
	scanf("%d %d\n", &n, &m);
	for(int i = 0; i < n; i++){
		scanf("%s", s[i]);
		for(int j = 0; j < m; j++) if(s[i][j] == '.') wh++;
	}
	if(s[0][0] == '.') qu.push(pair<P, int>(P(0, 0), 1));
	while(!qu.empty()){
		pair<P, int> tmp = qu.front(); qu.pop();
		if(tmp.first.first == n-1 && tmp.first.second == m-1){
			ans = tmp.second;
			break;
		}
		for(int i = 0; i < 4; i++) {
			int x = tmp.first.first + dx[i], y = tmp.first.second + dy[i];
			if(x < 0 || x >= n || y < 0 || y >= m || s[x][y] == '#') continue;
			qu.push(pair<P, int>(P(x, y), tmp.second + 1));
			s[x][y] = '#';
		}
	}
	printf("%d\n", ans ? wh - ans : -1);
}

Measured memory_bytes: 256
nums = Array.new
nums[0] = 0
i = 1
 
loop {
    nums[i] = gets.to_i
    if nums[i] == 0
        break
    end
    i += 1
}
 
i -= 1
cnt = 1
 
 
i.times do
    print "Case ",cnt,": ",nums[cnt],"\n"
    cnt += 1
end


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int mx = 0;
  int s = 0;
  queue<int> q;
  rep(i,n) p[i]++;
  rep(i,n){
    s+=p[i];
    q.push(p[i]);
    if (q.size() > k){
      s -= q.front(); q.pop();
    }
    if (q.size() == k){
      mx = max(mx,s);
    }
  }
  double ans = mx;
  ans /= 2;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> L(N);
    for(int i = 0; i < N; i++){
        cin >> L.at(i);
    }

    sort(L.begin(), L.end());
    reverse(L.begin(), L.end());

    int A = 0;

    for(int i = 0; i < K; i++){
        A += L.at(i);
    }

    cout << A << endl;
}

Measured memory_bytes: 256
from statistics import mean
import math
N=int(input())
X = [int(item) for item in input().split()]
meanX=mean(X)
underX = math.floor(meanX)
upperX = math.ceil(meanX)

underX=sum([(item-underX)**2 for item in X])
upperX=sum([(item-upperX)**2 for item in X])
print(underX if underX<upperX else upperX)

Measured memory_bytes: 5276
n = int(input())
s = input()

cnt = [[0 for i in range(3)] for i in range(n)]
colors = 'RGB'

for i in range(1, n):
    for j in range(3):
        cnt[i][j] = cnt[i - 1][j]
        if j == colors.find(s[i - 1]):
            cnt[i][j] += 1

ans = 0
for i in range(2, n):
    color = colors.find(s[i])
    ans += cnt[i][(color + 1) % 3] * cnt[i][(color + 2) % 3]

for i in range(1, n // 2 + 1):
    for j in range(n - 2 * i):
        if s[j] != s[j + i] and s[j] != s[j + i * 2] and s[j + i] != s[j + i * 2]:
            ans -= 1

print(ans)

Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000007
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define fo(i,n) for(long long int i=0;i<n;i++)
#define Fo(i,k,n) for(long long int i=k;i<n;i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x,y) fo(i,sizeof(x)/sizeof(x[0]))x[i]=y
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define uset unordered_set
#define umap unordered_map
#define endl "\n"
#define scanf(arr,n) fo(i,n)cin>>arr[i]
#define printf(x) cout<<x<<"\n"
typedef vector<int> vi;
typedef pair<int,int> pi;
void print (ll *arr, ll n) {fo(i,n){cout<<arr[i]<<" ";}cout<<"\n";}
bool isvaild (int i, int j, int n, int m) { return !( i < 0 or j < 0 or i > n-1 or j > m-1 );}

struct hash_pair {
    template<class T1, class T2>
    size_t operator()(const pair<T1,T2> &p) const 
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);

        return hash1^hash2;
    }
};
/*****************************MANASH**********************************/

umap<pi,int,hash_pair> m;


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

    //int t; cin>>t;
    //while (t--)
    {
        ll n;
        cin>>n;
        ll sum = 0;
        long long int i = 1;
        for (i=1; i < n+1; i++)
        {
            /* code */
            if(i%3 != 0 and i%5 != 0) sum+=i;
        }
         
        cout<<sum;
    }
    
	return 0;
}

Measured memory_bytes: 3580
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if (a+b) == c || (b+c) == a || (c+a) == b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1768
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

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

    vector<int> v(M, 0);
    for(int i = 0; i < N; ++i)
    {
        int ki;
        cin >> ki;
        while(ki--)
        {
            int ai;
            cin >> ai;
            v[ai - 1]++;
        }
    }
    int ans = 0;
    for(auto& e : v)
    {
        if(e == N)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

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

	ans += max({a, b, c}) * 10;
	ans += min({max(a, b), max(b, c), max(a, c)});
	ans += min({a, b, c});
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s;
  ll k;
  cin >> s >> k;
  ll n = s.size();

  ll cnt = 0;
  rep(i, n) {
    ll start = i;
    while (i+1 < n and s[i] == s[i+1]) {
      i++;
    }
    cnt += (i-start+1)/2;
  }
  ll front = 0;
  ll back = 0;
  rep(i, n) {
    if (s[0] != s[i]) break;
    front++;
  }
  rep(i, n) {
    if (s[n-1] != s[n-1-i]) break;
    back++;
  }
  cerr << n << endl;
  cerr << cnt << " " << front << " " << back << endl;
  if (n == front and front == back) cout << n*k/2 << endl;
  else cout << cnt*k + (s[0] == s[n-1] ? -1LL : 0LL) * (k-1)*(front/2+back/2-(front+back)/2) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	int n = sc.nextInt();
      	long odd = 1;
      	long ans;
      	
      	for(int i = 0;i < n;i++){
        	if(sc.nextInt()%2==0) odd *= 2;
        }
      	
      	ans = (long)Math.pow(3,n) - odd;
      
        System.out.println(ans);
             	
        
	}
}


Measured memory_bytes: 35812