akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

vector< bool > get_prime(int n){
  vector< bool > prime( n + 1, true);
  
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  
  for(int i = 2; i * i <= n; i++){
    if(prime[i]){
      for(int j = i + i; j <= n; j += i) prime[j] = false;
    }
  }
  
  return(prime);
}

int main(){
    string s;
    cin >> s;
    int a = 0, b = 0;
    char flag = s[0];
    REP(i, s.length()){
        if(s[i] != flag){
            a++;
            flag = s[i];
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int main(){
    int n; cin >> n;
    int p[n];
    rep(i,n) cin >> p[i];

    sort(p,p+n);

    ll ans = 0;
    rep(i,n){
        ans += p[i];
    }
    cout << ans - (p[n-1]/2) << endl;
    
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  str s, t; cin >> s >> t;
  ll ans  = 1000000;
  for(ll i = 0;i <= s.size() - t.size();i++)
  {
    ll tmp = 0;
    for(ll j = 0;j < t.size();j++)
    {
      if(s[i+j] != t[j]) tmp++;
    }
    ans = min(ans, tmp);
  }
  fin(ans);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int main(){
  ll s, t, k;
  cin >> s >> t >> k;
  if(s-k >= 0){
    s -= k;
  }else{
    if(s+t-k >= 0){
      t = s + t-k;
      s = 0;
    }else{
      s = 0;
      t = 0;
    }
  }
  cout << s << " " << t << endl;
}


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

int main(){
int K;
string S;
cin >> K >> S;

if(K>=S.size()){
	cout << S << endl;
}
else{
	for(int i=0;i<K;i++){
		cout << S.at(i);
	}
	cout << "..." << endl;
}
}

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

int N, M, Q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if(A.size() == N + 1) {
    int now = 0;
    for(int i = 0; i < Q; ++i) {
      if(A[b[i]] - A[a[i]] == c[i]) {
        now += d[i];
      }
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= M) {
    dfs(A);
    A.back()++;
  }
}


int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  cin >> N >> M >> Q;
  a = b = c = d = vector<int> (Q);
  for(int i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  dfs(vector<int> (1, 1));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int ans = 0, cur = 0; // 0: not yet, 1: up, -1 : down
    for (int i = 1; i < N; i++) {
        if (A[i-1] < A[i]) {
            if (cur == -1) {
                ++ans;
                cur = 0;
            } else if (cur == 0) {
                cur = 1;
            }
        } else if (A[i-1] > A[i]) {
            if (cur == 1) {
                ++ans;
                cur = 0;
            } else if (cur == 0) {
                cur = -1;
            }
        }
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner (System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int[] red = new int[a];
        int[] gre = new int[b];
        int[] col = new int[c];
        for(int i=0;i<a;i++) red[i] = in.nextInt();
        for(int i=0;i<b;i++) gre[i] = in.nextInt();
        for(int i=0;i<c;i++) col[i] = in.nextInt();
        int pta = a-1;
        int ptb = b-1;
        int ptc = c-1;
        long sum=0L;
        Arrays.sort(red);
        Arrays.sort(gre);
        Arrays.sort(col);
        ArrayList<Integer> lst = new ArrayList<>();
        for(int i=0;i<x;i++){
            lst.add(red[a-1-i]);
        }
        for(int i=0;i<y;i++){
            lst.add(gre[b-1-i]);
        }
        Collections.sort(lst);
        int pt = x+y-1;
        int pt2=c-1;
        for(int i=0;i<x+y;i++){
            if(pt2>=0 && col[pt2]>lst.get(pt)) {sum+=col[pt2];--pt2;}
            else {sum+=lst.get(pt);--pt;}
        }
        System.out.println(sum);
        
    }
}

Measured memory_bytes: 93988
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

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

	int a, b;
	cin >> a >> b;
	int d = a / b;
	int r = a % b;
	double f = a / (double)b;
	cout << d << " " << r << " " << PREC(5) << f << endl;
}


Measured memory_bytes: 3292
using System;

namespace B___ATCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            int max_count = 0;
            int count = 0;
            for (int i = 0; i < line.Length; i++)
            {
                if (line[i] == 'A' || line[i] == 'C' || line[i] == 'G' || line[i] == 'T')
                {
                    count++;
                    if (max_count < count)
                    {
                        max_count = count;
                    }
                }
                else
                {
                    count = 0;
                }
            }
            Console.WriteLine(max_count);
        }
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int X; cin >> X;
    cout << 10 - X/200 << ln;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    double n,m,d;cin>>n>>m>>d;
    double an;
    if(d==0)an=n/n/n*(m-1);
    else an=2*(n-d)/n/n*(m-1);
    cout<<setprecision(12)<<an<<endl;

}







Measured memory_bytes: 256
//No sorceries shall prevail.
import java.util.*;
import java.io.*;
public class Main {

	static Scanner inp= new Scanner(System.in);
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}

	
	
	//Main
	void main() {
		
		int n=inp.nextInt();
		int m=inp.nextInt();
		int q=inp.nextInt();
		int r[]=new int[n+1];
		int c[]=new int[m+1];
		HashSet<Long> set = new HashSet<>();
		while(q-->0) {
			int x=inp.nextInt();
			int y=inp.nextInt();
			set.add(hash(x,y));
			r[x]++;
			c[y]++;
		}
		int maxX=0,maxY=0;
		for(int i=0;i<=n;i++) {
			maxX=Math.max(maxX, r[i]);
		}
		for(int i=0;i<=m;i++) {
			maxY=Math.max(maxY, c[i]);
		}
		int gg=maxX+maxY-1;
		ArrayList<Integer> xs=new ArrayList<>();
		ArrayList<Integer> ys=new ArrayList<>();
		for(int i=0;i<=n;i++) {
			if(r[i]==maxX) xs.add(i);
		}
		for(int i=0;i<=m;i++) {
			if(c[i]==maxY) ys.add(i);
		}
		loop:
		for(int x: xs) {
			for(int y: ys) {
				if(!set.contains(hash(x,y))) {
					gg++;
					break loop;
				}
			}
		}
		System.out.println(gg);
	}
    
    static long hash(int x, int y) {
    	return x*1000000000l+y;
    }
		
}


Measured memory_bytes: 90608
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String t=sc.next();
    int a=sc.nextInt();
    int b=sc.nextInt();
    String u=sc.next();
    if(u.equals(s))
      a--;
    else
      b--;
    System.out.println(a+" "+b);
  }
}

Measured memory_bytes: 23380
import java.io.PrintWriter
import java.lang.StringBuilder

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    var x = readLong()
    val sb = StringBuilder()
    while (x > 0) {
        x -= 1
        sb.insert(0,  'a' + (x % 26).toInt())
        x /= 26
    }
    println(sb)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 34644
import collections
N = int(input())
lsa = list(map(str,input().split()))
lsb = collections.deque()
if N%2 == 0:
    for i in range(N):    
        if i % 2 == 0:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])
if N%2 == 1:
    for i in range(N):
        if i % 2 == 1:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])

print(' '.join(lsb))

Measured memory_bytes: 31684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main(){
  int n,a,b;string s;cin>>n>>a>>b>>s;
  int cntall=0,cnt=0;
 for (int i = 0; i < n; i++)
 {
   /* code */
   if (s[i]=='a'&&cntall<a+b)
   {
     /* code */
     cntall++;
     cout<<"Yes"<<endl;
   }
   else if (s[i]=='b'&&cntall<a+b&&cnt+1<=b)
   {
     /* code */
     cnt++;
     cntall++;
     cout<<"Yes"<<endl;
   }
   else
   {
     cout<<"No"<<endl;
   }
   
   
   
 }
 
  
  }

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define lepb(i,s,t) for(int i=(s);i>=(t);--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll inff = 4557430888798830399ll;
const db eps = 1e-10;
const db pi = acos(-1.0);
const ll mod = 1e9+7;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int L,z;vector<vector<int> > v;
	cin>>L;
	repb(i,1,18)v.pb({i,i+1,1<<(i-1)}),v.pb({i,i+1,0});
	z=0;
	lepb(i,19,1)
	{
		while(L>=(1<<(i-1)))
		{
			v.pb({i,20,z});
			z+=1<<(i-1);L-=1<<(i-1);
		}
	}
	cout<<20<<" "<<sz(v)<<endl;
	for(auto t:v)cout<<t[0]<<" "<<t[1]<<" "<<t[2]<<endl;
}

Measured memory_bytes: 256
// AtCoder Crackers

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int alloc_senbei = n % k;
    if (alloc_senbei) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  string s, t;
  cin >> s >> t;
  ll s_size = s.size();

  ll ans = 0;
  string::size_type before_f = 0;
  rep(i, t.size()) {
    string sub = s.substr(before_f, s.size() - before_f);
    string::size_type f = sub.find(t[i]);
    if (f == string::npos) {
      if ((ll)sub.size() == s_size) {
        COUT(-1);
        return 0;
      }
      before_f = 0;
      if (ans % s_size != 0) ans += s_size - ans % s_size;
      // もう一回検索
      string::size_type ff = s.find(t[i]);
      if (ff == string::npos) {
        COUT(-1);
        return 0;
      }
      ans += before_f + ff + 1;
      before_f = ff + 1;
      continue;
    }
    ans += f + 1;
    before_f = before_f + f + 1;
  }
  COUT(ans);

  return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
	
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define prime 1000000007

#define W(x) cerr << "\033[33m" << #x << " = " << x << "\033[0m" << "\n";

using namespace std;
int a, b, c, w, x, y, z, n; 
string s;

int ce(int a, int b){
	return (a+b-1)/b;
}

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

	if((a <= c && c <= b)||(a >= c && c >= b)){
		printf("Yes\n");
	}else printf("No\n");
	
	

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
set<char>t;
int main()
{
    string a;
    while(cin>>a)
    {
        if(a=="zyxwvutsrqponmlkjihgfedcba")
            printf("-1\n");
        else
        {
            int len=(int)a.size();
            if(len<26)
            {
                cout<<a;
                t.clear();
                for(int i=0;i<len;i++)
                    t.insert(a[i]);
                for(int i=0;i<26;i++)
                {
                    if(!t.count(s[i]))
                    {
                        printf("%c\n",s[i]);
                        break;
                    }
                }
            }
            else
            {
                if(a[len-1]=='z')
                {
                    for(int i=0;i<len-2;i++)
                        printf("%c",a[i]);
                    printf("z\n");
                }
                else
                {
                    int i;
                    char k='z';
                    char b[30];
                    int j=0;
                    for(i=len-1;i>0;i--)
                    {
                        b[j++]=a[i];
                        if(a[i]>a[i-1])
                            break;
                    }
                    int h=i;
                    char p=a[i-1];
                    for(int i=0;i<j;i++)
                    if(b[i]>p)
                    {
                        if(b[i]<k) k=b[i];
                    }
                    a[h-1]=k;
                    for(int j=0;j<=h-1;j++)
                        printf("%c",a[j]);
                    printf("\n");
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, i, j = 0, x, total[10000] = {0};

  while(1){
    total[j] = 0;
    scanf("%d", &n);
    if(n == 0)
      break;
    for(i = 0; i < n/4; i++){
      scanf("%d", &x);
      total[j] += x;
    }
    j++;
  }

  for(i=0; i<j; i++)
    printf("%d\n", total[i]);

  return 0;
}



Measured memory_bytes: 2112
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100000 + 47;

int X[MAX];
int DX[MAX];
int P[MAX];
int T[MAX];
int RES[MAX];
int n, m;
LL k;

void mult(int P[], int Q[])
{
	FOR(i, 0, n - 1) T[i] = Q[i];
	
	FOR(i, 0, n - 1)
	{
		P[i] = T[P[i]];
	}
}

void bp(int P[], LL k, int RES[])
{
	FOR(i, 0, n - 1) RES[i] = i;

	while (k)
	{
		if (k & 1) mult(RES, P);

		mult(P, P);
		k >>= 1;
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	FOR(i, 0, n) cin >> X[i];

	FOR(i, 0, n - 1)
	{
		DX[i] = X[i + 1] - X[i];
	}

	FOR(i, 0, n - 1)
	{
		P[i] = i;
	}

	cin >> m >> k;
	FOR(i, 0, m)
	{
		int a;
		cin >> a;
		a--;
		swap(P[a - 1], P[a]);
	}

	bp(P, k, RES);

	cout << X[0] << "\n";
	LL x = X[0];

	FOR(i, 0, n - 1)
	{
		x += DX[RES[i]];
		cout << x << "\n";
	}
}

Measured memory_bytes: 3200
import java.util.Scanner;

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        long[] ary = new long[200000];
        
        for(int i=0; i<n; i++){
            ary[i] = Long.parseLong(sc.next());
        }

        for(int i=k; i<n; i++){
            if(ary[i] > ary[i - k]){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 62060
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);
    let ab = get!(u64, u64; n);

    let aa: Vec<u64> = ab.iter().map(|t| t.0).collect();
    let bb: Vec<u64> = ab.iter().map(|t| t.1).collect();

    let mut sum = 0;
    for (&a, &b) in aa.iter().rev().zip(bb.iter().rev()) {
        sum += (b - (a + sum) % b) % b;
    }

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


Measured memory_bytes: 8444
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int A, B;
  
  scanf("%d %d", &A, &B);
  
  //Aを2回押す
  if( ( A - B ) >= 1 ) {
    printf("%d", ( A + ( A - 1)));
  }
  //Bを2回押す
  else if(( A - B ) <= -1) {
    printf("%d", ( B + ( B - 1)));
  }
  //AとBを1回ずづ押す
  else {
    printf("%d", ( A + B ));
  }
  
  return 0;
}

Measured memory_bytes: 128
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  9/29 23:41:20 2018

*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int main()
{
	int a, b, c, ans = 0;
	scanf("%d %d %d", &a, &b, &c);
	if(a != b){
		if(a == c || b == c) ans = 2;
		else ans = 3;
	}
	else if(a == b){
		if (a == c) ans = 1;
		else ans = 2;
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define SIZE 300001
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for (int i = 0; i<SIZE; i++)
		{
			par[i] = i;
			ran[i] = 0;
			ren[i] = 1;
		}
	}
	int find(int a)
	{
		if (a == par[a])return a;
		else return par[a] = find(par[a]);
	}
	void unite(int a, int b)
	{
		a = find(a);
		b = find(b);
		if (a == b)return;
		if (ran[a]>ran[b])
		{
			par[b] = a;
			ren[a] += ren[b];
		}
		else
		{
			par[a] = b;
			ren[b] += ren[a];
		}
		if (ran[a] == ran[b])ran[b]++;
	}
};
unionfind uf;
typedef long long ll;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
int main()
{
	int num, mx, my;
	scanf("%d%d%d", &num, &mx, &my);
	vector<pi3>v;
	for (int i = 0; i < num; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za--, zb--;
		v.push_back(make_pair(zc, make_pair(za, zb)));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	uf.init();
	ll ans = 0;
	for (int i = 0; i < num; i++)
	{
		int t = 0;
		int x = v[i].second.first, y = v[i].second.second;
		x = uf.find(x), y = uf.find(mx + y);
		if (x != y)t = uf.ren[x] + uf.ren[y];
		else t = uf.ren[x];
		if (t > 0)
		{
			ans += v[i].first;
			uf.unite(x, y);
			x = uf.find(x);
			uf.ren[x]--;
		}
	}
	printf("%lld\n", ans);
}

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

int main() {
    string x,y;
    cin >>x >> y;

    if (x<y){
    cout <<'<' << endl;

    }else if(x>y){
    cout <<'>' << endl;

    }else{
    cout <<'=' << endl;

    }
    return 0;
}


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

typedef unsigned long long ull;
#define FOR(i, a, b) for (ull i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const ull mod = 1e9 + 7;

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

	ull N,S=0;	cin>>N;
	FOR(i,1,N+1){
		if((i%3!=0)&&(i%5!=0)) S+=i;
	}
	cout<<S<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF=1000000000000000000;

int n,k;
struct dat{
    int s,e,c;
    dat(int S,int E,int C){
        s=S;
        e=E;
        c=C;
    }
};
vector<dat> v;

struct node{
  int s,e,m;
  long long val,lazy;
  node *l,*r;
  node(int _s,int _e){
    s=_s,e=_e,m=(s+e)>>1;
    if (s==e){
    }
    else{
      l=new node(s,m);
      r=new node(m+1,e);
    }
    val=lazy=INF;
  }
  void prop(){
    l->val=min(l->val,val);
    r->val=min(r->val,val);
  }
  long long query(int i){
    if (s==e) return val;
    else{
        prop();
        if (i<=m) return l->query(i);
        else return r->query(i);
    }
  }
  void update(int i,int j, long long k){
    if (i==s && j==e){
        val=min(val,k);
        return;
    }
    else{
        if (j<=m) l->update(i,j,k);
        else if (m<i) r->update(i,j,k);
        else l->update(i,m,k),r->update(m+1,j,k);
    }
  }
}*root;


int main(){
    scanf("%d%d",&n,&k);
    int a,b,c;
    while (k--){
        scanf("%d%d%d",&a,&b,&c);
        v.push_back(*new dat(a,b,c));
    }

    sort(v.begin(),v.end(),[](dat &i, dat &j){
        return i.s<j.s;
    });
    root=new node(0,n);
    root->update(1,1,0);

    for (vector<dat>::iterator it=v.begin();it!=v.end();it++){
        root->update((*it).s+1,(*it).e, root->query((*it).s)+(*it).c );
    }

    printf("%lld\n",(root->query(n)==INF)?-1:root->query(n));
}


Measured memory_bytes: 16692
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int s(int x){
    int sum = 0;
    while(x > 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main(void){

    int N, A, B;

    scanf("%d%d%d", &N, &A, &B);

    int ans = 0;

    for(int i = 1; i <= N; i++){
        int x = i, y = i;
        if(A <= s(x) && s(x) <= B){
            ans += y;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=1<<29; 
int n;
int d[16][16];
int dp[1<<16][16];

int main(){
  int m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      d[i][j]=INF;
    }
  }
  int v1,v2,cost;
  for(int i=0;i<m;i++){
    cin>>v1>>v2>>cost;
    d[v1][v2]=cost; 
  }
  
  for(int S=0;S<1<<n;S++){
    fill(dp[S],dp[S]+n,INF);
  }
  dp[(1 << n)-1][0]=0;
  
  for(int S=(1<<n)-2;S>=0;S--){
    for(int v=0;v<n;v++){
      for(int u=0;u<n;u++){
	if(!(S>>u&1)){ 
	  dp[S][v]=min(dp[S][v],dp[S|1<<u][u]+d[v][u]);
	}
      }
    }
  }
  if(dp[0][0]==INF){
    cout<<-1<<"\n";
  }else{
    cout<<dp[0][0]<<"\n";
  }
  return 0;
}
  



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

int main() {
  int64_t n;
  double s;
  cin >> n;
  vector<int64_t> x(n), y(n);
  for(int i = 0; i < n; ++i) cin >> x.at(i) >> y.at(i);
  for(int i = 0; i < n-1; ++i){
    for(int j = i+1; j < n; ++j){
      int64_t xd = x.at(j) - x.at(i), yd = y.at(j) - y.at(i);
      s += pow(xd*xd + yd*yd, 0.5);
    }
  }
  cout << fixed << setprecision(7) << s * 2 / n << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            var balls = Console.ReadLine().Split(' ')
                .Select<string, int>(x => int.Parse(x));
            if (Solve(balls))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }

    static bool Solve(IEnumerable<int> balls)
    {
        bool res = true;
        var b = new List<int>();
        var c = new List<int>();
        foreach (int e in balls)
        {
            if (b.Count == 0 || b.Last() < e)
            {
                b.Add(e);
            }
            else if (c.Count == 0 || c.Last() < e)
            {
                c.Add(e);
            }
            else
            {
                res = false;
                break;
            }
        }

        return res;
    }
}

Measured memory_bytes: 5672
x = list(map(int, input().split()))
MOD = 10 ** 9 + 7
if abs(x[0] - x[1]) > 1:
    print(0)
else:
    ans = 1
    for i in range(max(x)):
        for j in range(2):
            ans *= max(1, x[j] - i)
            ans = ans % MOD
    if x[0] == x[1]:
        print(ans * 2 % MOD)
    else:
        print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a!=1&&b!=1){
		if(a > b)puts("Alice");
		else if(a==b)puts("Draw");
		else puts("Bob");
		}
	else {
		if(a==b){
			puts("Draw");
			}
		else if(a==1&&b!=1){
			puts("Alice");
			}
		else puts("Bob");
		}
	return 0;
	}


Measured memory_bytes: 256
import sys

N=int(input())
st=0
en=N
print(st)
sys.stdout.flush()
s=input().split()
if s=="Vacant":
  sys.exit()
a=st
b=en
c=s
d=s

for i in range(19):
  x=(a+b)//2
  print(x)
  sys.stdout.flush()
  f=input().split()

  if f=="Vacant":
    sys.exit()
  elif (x-a)%2==0 and c!=f:
    b=x
    d=f
  elif (x-a)%2==0 and c==f:
    a=x
    c=f
  elif (x-a)%2==1 and c!=f:
    a=x
    c=f
  elif (x-a)%2==1 and c==f:
    b=x
    d=f

Measured memory_bytes: 3660
#include <vector>
#include <iostream>
#include <complex>

#define fs first
#define sc second

using namespace std;

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
const D EPS=1e-12;


namespace std{
  bool operator<(const P &a, const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

D cross(P x, P y){return imag(conj(x)*y);}

bool para(L a, L b){return abs(cross(a.fs - a.sc, b.fs-b.sc))<EPS;}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    D x1, y1, x2, y2, x3, y3, x4, y4;
    cin >>  x1 >> y1 >> x2 >> y2 >>  x3>> y3>> x4>> y4;
    P A = P(x1, y1);
    P B = P(x2, y2);
    P C = P(x3, y3);
    P D = P(x4, y4);
    L AB = L(A, B);
    L CD = L(C, D);
    if(para(AB, CD)){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}





Measured memory_bytes: 3224
X, Y = map(int, input().split())
ans = 0
if X == 1:
    ans += 300000
if Y == 1:
    ans += 300000
if X == 2:
    ans += 200000
if Y == 2:
    ans += 200000
if X == 3:
    ans += 100000
if Y == 3:
    ans += 100000
if X == 1 and Y == 1:
    ans += 400000
print(ans)
 

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m; cin>>n>>m;
    vector<vector<pp>> path(n);
    set<pp> se;
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        path[a].push_back(mk(b,c));
        path[b].push_back(mk(a,c));
        se.insert(mk(a,b));
    }
    rep(i,n){
        int cost,s,to,w;
        priority_queue<pp, vector<pp>, greater<pp>> pq;
        pq.push(mk(0,i));
        vector<int> d(n,inf);
        d[i]=0;
        while(!(pq.empty())){
            tie(cost,s)=pq.top();
            pq.pop();
            if(d[s]!=cost) continue;
            for(auto p:path[s]){
                tie(to,w)=p;
                if(d[to]>d[s]+w){
                    d[to]=d[s]+w;
                    pq.push(mk(d[to],to));
                }
            }
        }
        queue<int> que;
        que.push(i);
        while(!(que.empty())){
            s=que.front();
            que.pop();
            for(auto p:path[s]){
                tie(to,w)=p;
                if(d[to]-d[s]==w){
                    if(se.count(mk(s,to))) se.erase(mk(s,to));
                    if(se.count(mk(to,s))) se.erase(mk(to,s));
                    que.push(to);
                }
            }
        }
    }
    cout<<se.size()<<endl;
}

Measured memory_bytes: 384
import Control.Monad
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as BS
main=do
 [h,w]<-map read.words<$>getLine
 s<-replicateM h (BS.unpack<$>BS.getLine)
 print ((\n-> if n<0 then n else ((h*w)-(black s 0)-n)) (wfs h w s [(1,1,1)] (S.insert (1,1) S.empty)))
 where black [] i = i
       black (t:s) i = black s (i+(length (filter (=='#') t)))
       wfs _ _ _ [] _ = -1
       wfs h w s ((x,y,i):q) ac | x==h&&y==w = i
                                | x>h||x<1||y>w||y<1 = wfs h w s q ac
                                | ((s!!(x-1))!!(y-1))=='#' = wfs h w s q ac
                                | otherwise  = wfs h w s (push x y (i+1) q ac) (ins ac x y)
       ins ac x y = S.union ac (S.fromList [(x-1,y),(x,y-1),(x,y+1),(x+1,y)])
       push x y i q ac = q++[(uo (x-1) y i ac),(uo x (y-1) i ac),(uo x (y+1) i ac),(uo (x+1) y i ac)]
       uo x y i ac = if (S.member (x,y) ac) then (0,0,0) else (x,y,i)

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
string haiku;
cin>>haiku;
for (int i = 0; i < 19; i++)
{
    if (haiku.at(i)==',')
    {
        cout<<" ";
    }
   else
   {
       cout<<haiku.at(i);
   }
   
}
cout<<endl;
    
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n]; 
    int odd = 0,even = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] % 2 == 0) even++;
        else if (a[i] % 2 == 1) odd++;
    }
    if(odd % 2 == 0){
        cout << "YES" << endl; 
    }else{ 
        cout << "NO" << endl;
    }


    return 0;
}

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

long long kaijo(long long n);

int main()
{
    long long a;
    cin >> a;
    cout << kaijo(a) << endl;
    return 0;
}

long long kaijo(long long n)
{
    return (n==1) ? 1 : n*kaijo(n-1);
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y)   for (__typeof(x) i = x; i > y; i--)
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ll mod=1000000007;
const ll AM=2e5+5;
using namespace std;
int main()
{
    fast;
    ll x; cin>>x;
    ll in=100,cnt=0;
    while(in<x)
    {
    	in+=0.01*in;
    	cnt++;
    }
    cout<<cnt;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int D[51];
int freq[13];

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> D[i];
    for(int i = 0; i < N; i++) freq[D[i]]++;
    
    if(freq[0] >= 1 || freq[12] > 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i < 12; i++){
        if(freq[i] > 2){
            cout << 0 << endl;
            return 0;
        }
    }


    int ans = 0;
    for(int mask = 0; mask < (1 << 22); mask++){
        int cnts[13] = {};
        // 0-23に値を割り当てて、計算する
        int table[50] = {};
        for(int i = 0; i < 22; i++){
            if((mask >> i) & 1){
                int idx = -1;
                // 1-11
                if(i < 11){
                    idx = i + 1;
                    table[i + 1]++;
                }
                // 13-23
                else{
                    table[(i + 2)]++;
                    idx = 24 - (i + 2);
                }
                cnts[idx]++;
            }
        }
        bool ok = true;
        for(int i = 1; i < 12; i++){
            if(freq[i] != cnts[i]){
                ok = false;
            }
        }
        if(!ok) continue;
        table[0 ]++;
        table[12] += freq[12];
        int ptime = -1;
        int minv = 1<<29;
        for(int i = 0; i < 24; i++){
            table[i+24]=table[i];
        }
        for(int i = 0; i < 48; i++){
            if(table[i]){
                // cout << i << " ";
                if(ptime != -1){
                    minv = min(minv, (i - ptime));
                }
                ptime = i;
            }
        }
        // cout << endl;
        ans = max(ans, minv);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 40

int n,pos=0;
int cout = 0;
int Pre[MAX],In[MAX],Ans[MAX];

int distance(int start,int key){
  int i,count=0;
  for(i=start;i<MAX;i++){
    if(In[i]!=key)
      count++;
    else break;
  }
  return count;
}
  
  
int solve(int l,int r){
  int root,d;
  if(l-r>=0)return -1;
  root=Pre[pos];
  pos++;
  d=distance(0,root);
  if(d>n)return -1;
  solve(l, d);
  solve(d+1, r);
  Ans[cout++]=root;
  return 0;
}

int main(){
  int m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&m);
    Pre[i]=m;
  }
  for(i=0;i<n;i++){
      scanf("%d",&m);
      In[i]=m;
  }
  solve(0,n);

  printf("%d",Ans[0]);
  for(i=1;i<n;i++)
    printf(" %d",Ans[i]);
  printf("\n");
	   
  return 0;
}
    

Measured memory_bytes: 600
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    x = input()
    s = []
    for c in x:
    	if len(s) == 0:
    		s.append(c)
    	elif c == 'T' and s[-1] == 'S':
    		s.pop()
    	else:
    		s.append(c)
    print(len(s))
 
main()


Measured memory_bytes: 5096
#include "bits/stdc++.h"
using namespace std;


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

    int count = 0;

    for (int i=0; i < N; i++) {
        cin >> S;
        if (S == 'Y') {
            count =count+1 ;
            cout << "Four" << endl;
            break;
        }
    }
    if (count ==0) {
        cout << "Three" << endl;
    }
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	int ans = 0;
	for (int i = 0; i <= sqrt(n); i++)
	{
		ans = i * i;
	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>

using ll = long long;
using namespace std;

/* initialize */
vector<int> A[100000];
int c[100000];
/* main */
void dfs(int r, int d){
    stack<int> S;
    S.push(r);
    c[r] = d;
    while (!S.empty()){
        int u = S.top(); S.pop();
        for (int v : A[u]) {
            if ( c[v] == -1){
                c[v] = d;
                S.push(v);
            }
        }
    }
}
int main() {
    int n, m, k, l;
    cin >> n;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &k, &l);
        A[k].push_back(l);
        A[l].push_back(k);
    }
    int id = 1;
    for (int i = 0; i < n; ++i) {
        c[i] = -1;
    }
    for (int j = 0; j < n; ++j) {
        if (c[j] == -1) dfs(j,id++);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> k >> l;
        if(c[k] == c[l]) cout << "yes\n";
        else cout << "no\n";
    }
    return 0;
}


Measured memory_bytes: 9028
in_li = list(map(int,input().split()))
A = in_li[0]
B = in_li[1]
K = in_li[2]
if A + B <= K :
    print("0 0")
else :
    if A > K :
        print(A-K,"",B)
    elif B > K - A :
        print("0",B-(K-A))


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#define swap(x, y){int z; z = y; y = x; x = z;}

int main()
{
	int a, b;
	while(scanf("%d %d", &a, &b))
	{		
		if( a == 0 && b == 0)
		{
			break;
		}
		if(a > b)
		{
			swap(a, b);
			printf("%d %d\n", a, b);				
		}
		else
		{
			printf("%d %d\n", a, b);
		}		
	}
	return 0;	
}


Measured memory_bytes: 2616
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

d,n = li()

if n<100:
    print(n*(100**d))
else:
    print(101*(100**d))
    

Measured memory_bytes: 3064
n = int(input())
w = list(map(int, input().split()))
wlr = [0] * (len(w) + 1)
for i in range(n):
    wlr[i + 1] = wlr[i] + w[i]

w.reverse()
wrl = [0] * (len(w) + 1)
for i in range(n):
    wrl[i + 1] = wrl[i] + w[i]
wrl.reverse()

#print(wlr)
#print(wrl)

best = sum(w) * 2
for lr, rl in zip(wlr, wrl):
    if abs(lr - rl) < best:
        best = abs(lr - rl)
print(best)


Measured memory_bytes: 3064