akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
{
	static void Main(string[] args)
	{
         int N = int.Parse( Console.ReadLine() );
         string[] aa = Console.ReadLine().Split(' ');
         int[] inputs = new int[ N ];
for(int i = 0; i < N; i++)
{
   inputs[ i ] = int.Parse( aa[ i ] );
}




         for(int i = 0; i < N-1; i++)
{
   if(inputs[ i ] > inputs[ i+1 ])
   {
   int a = inputs[ i ];
   inputs[ i ] = inputs[ i+1 ];
   inputs[ i+1 ] = a;
   }
}

         
         int score = 4000001;
         int alignNum = -100;
         bool loopWhile = false;
         
         do
{
int scoreP = 0;
loopWhile=false;

      for (int i =0; i < N; i++)
      {
int a = (alignNum - inputs[ i ]);
scoreP += a*a; 
      }

      if (score > scoreP)
          {
          loopWhile =true;
          score = scoreP;
          alignNum++;
          }
}
         while(loopWhile);

Console.WriteLine(score);

	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, k;
ll a[200005];
ll b[200005];

int main()
{
    scanf("%lld%lld", &n, &k);
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    ll cnt = 1;
    ll i;
    for(i = 1; b[i] == 0; i = a[i], cnt++)
    {
        b[i] = cnt;
        k--;
        if(k < 0)
        {
            printf("%lld\n", i);
            return 0;
        }
    }
    ll x = cnt - b[i];
    k %= x;
    while(k > 0)
    {
        i = a[i];
        k--;
    }
    printf("%lld\n", i);
    return 0;
}


Measured memory_bytes: 6964
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	cin >> a;
	sort(ALL(a));
	cout << distance(a.begin(), unique(ALL(a))) << endl;

	return 0;
}


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

int main() {
    int n;
    cin >> n;

    int R[101];
    int C[101];
    int A[101][101];
    for (int i = 1; i <= n; i++) {
        cin >> R[i] >> C[i];
        A[i][i] = 0;
    }

    for (int k = 2; k <= n; k++) {
        for (int i = 1; i <= (n - k + 1); i++) {
            int j = i + k - 1;
            A[i][j] = 10000001;
            for (int l = i; l < j; l++) {
                A[i][j] = min(A[i][j], A[i][l] + A[l+1][j] + (R[i] * C[l] * C[j]));
            }
        }
    }

    cout << A[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3116
import java.util.*;

public class Main {
    static Scanner scanner;
    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        new ABC166A().main();
    }
    static class ABC166A {
        public void main()
        {
            System.out.println(scanner.next().equals("ABC")?"ARC":"ABC");
        }
    }
}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define MOD 1000000007
#define inf 1e18
#define deb(x) cout << #x << " -> " << x << "\n";

#ifdef LOCAL_DEFINE
	mt19937 rng(228);
#else 
	mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	cout.precision(10);
	cout << fixed;
	int n;
	cin >> n;
	cout << (1000 - n % 1000) % 1000 << "\n";
	return 0;
}


Measured memory_bytes: 3664
from collections import deque
def resolve():
    def calc(seq):
        score = 0
        for a, b, c,d in query:
            if seq[b-1] - seq[a-1] == c:
                score += d
        return score


    N, M, Q = map(int, input().split())
    query = [list(map(int, input().split())) for _ in range(Q)]

    q = deque()
    for i in range(1, M+1):
        q.append([i])
    ans = 0
    while q:
        seq = q.popleft()
        if len(seq) == N:
            score = calc(seq)
            ans = max(ans, score)
        else:
            for i in range(seq[-1], M+1):
                nx_seq = seq + [i]
                q.append(nx_seq)
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 23168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int N;cin>>N;
    int A[N];
    rep(i,N)cin>>A[i];
    vector<int>V(1000005,0);
    rep(i,N){
        V[A[i]]++;
    }
    int ans=0;
    for(int i=1;i<=1000000;i++){
        if(V[i]==0)continue;
        if(V[i]==1)ans++;
        int m=i;
        for(int j=1;m*j<=1000000;j++){
            V[m*j]=0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12680
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = (1e+9)+7;
typedef pair<ll, ll> LP;
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1);
}
 
int main()
{
  int a;
  cin >> a;
  if(a>=105&&a<135)printf("1");
  else if(a>=135&&a<165)printf("2");
  else if(a>=165&&a<189)printf("3");
  else if(a>=189&&a<195)printf("4");
  else if(a>=195&&a<201)printf("5");
  else printf("0");
}

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

int main()
{
 int h,m,s, S;

 cin >> S;  

 s= S % 60;  
 S /= 60;    
 m= S % 60;  
 h = S / 60;

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

 return 0;
}


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

int main(){
	string S; cin >> S;
	int64_t ret = 0, n = S.size();
	for(int i=0; i < 1<<n-1; ++i){
		int st = 0;
		for(int j=0; j < n-1; ++j){
			if (i>>j & 1){
				ret += stol(S.substr(st, j + 1 - st));
				st = j + 1;
			}
		}
		ret += stol(S.substr(st, n - st));
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int main()
{
	int a[5],x,y,i,*p;
	for(;;)
	{
		for(i=0;i<5;++i)
		{
			if(scanf("%d%d",&x,&y),!x&&!y)return 0;
			a[i]=x+y;
		}
		p=std::max_element(a,a+5);
		printf("%c %d\n","ABCDE"[p-a],*p);
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define REP(i,n) for(int i=0;i<n;i++)
	#define FOR(i,a,b) for(int i=a;i<=b;i++)
	#define FORR(i,a,b) for(int i=a;i>=b;i--)
	#define ALL(c) (c).begin(),()c.end() 

	#define PI 3.14159265358979323846
	const int N = 500 + 10;  
   

   int maxi,tot;
   void solve() {
	   int n;
	   cin>>n;
	   string s;
	   cin>>s;
	   int  len=s.size(); 
	   for(int i=0;i<len;i++) {
		     if(s[i]=='.')
		        tot++;
		   }
		   
		   int wyn=0;
		   int yan=tot;
	for(int i=0;i<len;i++) {
		   if(s[i]=='#')
		       wyn++;
		       
		   yan=min(yan,tot+wyn-(i+1-wyn)  );
		   
		       
		}
		
		
		cout<<yan;
	   			     
	   
	   }
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 720
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	for (int p, q; scan(p, q);) {
		unordered_map<int, int> m;
		int i {};
		do {
			m[p] = i++;
			p *= 10;
			out(p / q);
			p %= q;
		} while (p && !m.count(p));
		outl();
		if (p) {
			times(j, m[p])
				out(' ');
			times(j, i - m[p])
				out('^');
			outl();
		}
	}
}


Measured memory_bytes: 2564
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;
constexpr long long MOD = 998244353;

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

int main()
{
  int N, S;
  std::cin >> N >> S;
  std::vector<int> A(N);
  for(auto& val:A)
    std::cin >> val;
  std::vector<std::vector<long long>> dp1(N, std::vector<long long>(S + 1, 0));
  std::vector<std::vector<long long>> dp2(N, std::vector<long long>(S + 1, 0));
  if(A[0] <= S)
  {
    dp1[0][A[0]] = 1;
    dp2[0][A[0]] = 1;
  }
  for(int i = 1; i < N; ++i)
  {
    for(int s = 1; s <= S; ++s)
    {
      dp1[i][s] = dp1[i-1][s];
      auto x = s-A[i];
      if(0<x&&x<=S)
        dp1[i][s] += dp1[i-1][x];
      dp1[i][s] %= MOD;
      if(s==A[i])
        dp1[i][s] += i+1;
      dp1[i][s] %= MOD;
      dp2[i][s] = (dp2[i-1][s]+dp1[i][s])%MOD;
    }
  }
  std::cout << dp2.back().back() << std::endl;
  return 0;
}



Measured memory_bytes: 141184
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    cout << x2 - (y2 - y1) << " ";
    cout << y2 + (x2 - x1) << " ";
    cout << x1 - (y2 - y1) << " ";
    cout << y1 + (x2 - x1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int four_pow (int n) {
  if(n == 1) return 4;
  return 4 * four_pow(n-1);
}

int main() {
  // napsack?
  int n, a, b, c,k;
  vector<int> l;
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) {
    cin >> k;
    l.push_back(k);
  }
  int min = 2147483640;
  for (int cnt = 0; cnt < four_pow(n); cnt++) {
    int cnt0 = cnt;
    long long int fa = 0, fb = 0, fc = 0, mp = 0;
    for (int i = 0; i < n; i++) {
      if(cnt0 % 4 == 1) {
        if (fa) mp += 10;
        fa += l.at(i);
      } else if (cnt0 % 4 == 2) {
        if (fb) mp += 10;
        fb += l.at(i);
      } else if (cnt0 % 4 == 3) {
        if (fc) mp += 10;
        fc += l.at(i);
      }
      cnt0 /= 4;
    }
    if (fa == 0 || fb == 0 || fc == 0) continue;
    mp += (a - fa > 0 ? a - fa : fa - a);
    mp += (b - fb > 0 ? b - fb : fb - b);
    mp += (c - fc > 0 ? c - fc : fc - c);
    if (mp < min) min = mp;
  }
  cout << min << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;
typedef long long ll;
typedef pair<int, int> P;
vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank;

    UnionFind(int n = 1)
    {
        init(n);
    }

    void init(int n = 1)
    {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x)
    {
        if (par[x] == x) {
            return x;
        } else {
            int r = root(par[x]);
            return par[x] = r; // 辺の縮約（一度根をたどったら辺を直接根に向かって貼り直す）
        }
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (rank[x] < rank[y])
            swap(x, y);
        if (rank[x] == rank[y])
            ++rank[x];
        par[y] = x; // xよりyのほうが高さが小さい木
        return true;
    }
};

// 最大公約数
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

// 最小公倍数
int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y)
{
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

// 負の数にも対応した % 演算
long long mod(long long val, long long m)
{
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}

// a^n modを計算する
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    // nを2進数表示して1が埋まっている桁に関してはa^mをかけていく
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod)
{
    return modpow(a, mod - 2, mod);
}

int main()
{
    string S;
    cin >> S;
    string ans;
    for (int i = 0; i < S.size(); i++) {
        ans += 'x';
    }
    cout << ans << endl;
}

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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int X = int.Parse(input[1]);
            
            List<int> donuts = new List<int>();
            for(int i = 0 ; i < N ; i++)
            {
                donuts.Add(int.Parse(Console.ReadLine()));
            }
            
            int a = donuts.Sum();
            donuts.Sort();
            
            Console.WriteLine(N + ((X - a)/donuts[0]));
        }
    }
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int a[200001] = {};
    for(int i = 0; i < M; ++i){
        int p, q;
        cin >> p >> q;
        if(p > q) swap(p, q);
        if(p != 1 && q != N){
            continue;
        }else if(p == 1){
            if(a[q] == 1){
                cout << "POSSIBLE" << endl;
                return 0;
            }else{
                a[q] = 1;
            }
        }else if(q == N){
            if(a[p] == 1){
                cout << "POSSIBLE" << endl;
                return 0;
            }else{
                a[p] = 1;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
#define ll long long

void solve();
ll dfs(int i, int j, ll sum);
ll plus_sum(int i, int j);
ll ten(string t);

string s;
int n;

int main() {
  cin >> s;

  n = (int)(s.size());

  solve();

  return 0;
}

void solve() {

  cout << dfs(1,0,0) << endl;
}

ll dfs(int i, int j, ll sum) {

  if(i==n) {
    return sum + plus_sum(i, j);
  }

  return dfs(i+1, i, sum+plus_sum(i, j)) + dfs(i+1, j, sum);
}

ll plus_sum(int i, int j) {
  string t;

  for(int k=j; k<i; ++k)
    t += s[k];

  return ten(t);
}

ll ten(string x) {
  int len = (int)(x.length());
  ll ten = 1;
  rep(k, len-1) ten *= 10;
  ll sum = 0;

  for(int k=0; k<len; ++k) {
    int num = x[k]-'0';
    sum += num*ten;
    ten /= 10;
  }

  return sum;
}


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

#define CMD_ENQUEUE 0
#define CMD_FRONT 1
#define CMD_DEQUEUE 2

#define SIZE 200000

typedef int Item;

struct queue
{
    int head, tail;
    Item * list;
};

typedef struct queue * Queue;

Queue createQueue(void);
bool isEmpty(Queue);
bool isFull(Queue);
void enqueue(Queue, int);
void dequeue(Queue);
Item * front(Queue);

int main(void)
{
    int i, n, q, cmd, t, x;
    Queue * L;

    scanf("%d %d", &n, &q);
    L = (Queue *) malloc(sizeof(Queue) * n);
    for (i = 0; i < n; i++)
        L[i] = createQueue();

    while (q--) {
        scanf("%d %d", &cmd, &t);
        switch (cmd) {
        case CMD_ENQUEUE:
            scanf("%d", &x);
            enqueue(L[t], x);
            break;
        case CMD_FRONT:
            if (front(L[t]))
                printf("%d\n", *front(L[t]));
            break;
        case CMD_DEQUEUE:
            dequeue(L[t]);
        }
    }

    return 0;
}

Queue createQueue(void)
{
    Queue q = (Queue) malloc(sizeof(struct queue));
    q->head = q->tail = 0;
    q->list = (Item *) malloc(SIZE * sizeof(Item));
    return q;
}

bool isEmpty(Queue q)
{
    return q->head == q->tail;
}

bool isFull(Queue q)
{
    return (q->tail + 1) % SIZE == q->head;
}

void enqueue(Queue q, int x)
{
    if (isFull(q)) return;
    q->list[q->tail] = x;
    q->tail = (q->tail + 1) % SIZE;
}

void dequeue(Queue q)
{
    if (isEmpty(q)) return;
    q->head = (q->head + 1) % SIZE;
}

Item * front(Queue q)
{
    if (isEmpty(q)) return NULL;
    return q->list + q->head;
}



Measured memory_bytes: 6564
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> list = new ArrayList<>();
		long[] x = new long[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextLong();
			list.add(x[i]);
		}
		Collections.sort(list);
		for(int i = 0; i < n; i++) {
			if(x[i] < list.get(n / 2)) {
				System.out.println(list.get(n / 2));
			} else {
				System.out.println(list.get(n / 2 - 1));
			}
		}

	}

}


Measured memory_bytes: 98788
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func grouping(friend [][]int, group []int, p, id int) {
	var dfs func(p int)
	dfs = func(p int) {
		for _, f := range friend[p] {
			if group[f] == 0 {
				group[f] = id
				dfs(f)
			}
		}
	}
	dfs(p)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m, k := nextInt(), nextInt(), nextInt()
	friend, block := make([][]int, n), make([][]int, n)
	for i := 0; i < n; i++ {
		friend[i], block[i] = make([]int, 0), make([]int, 0)
	}
	for i := 0; i < m; i++ {
		a, b := nextInt()-1, nextInt()-1
		friend[a] = append(friend[a], b)
		friend[b] = append(friend[b], a)
	}
	for i := 0; i < k; i++ {
		c, d := nextInt()-1, nextInt()-1
		block[c] = append(block[c], d)
		block[d] = append(block[d], c)
	}

	id := 0
	group := make([]int, n)
	cnt := map[int]int{}
	for i := 0; i < n; i++ {
		if group[i] == 0 {
			id++
			group[i] = id
			grouping(friend, group, i, id)
		}
		cnt[group[i]]++
	}

	sameGroupBlock := make([]int, n)
	for i := 0; i < n; i++ {
		for _, j := range block[i] {
			if group[i] == group[j] {
				sameGroupBlock[i]++
			}
		}
	}

	for i := 0; i < n; i++ {
		ans := cnt[group[i]] - 1 - len(friend[i]) - sameGroupBlock[i]
		if i < n-1 {
			putf("%d ", ans)
		} else {
			puts(ans)
		}
	}
}


Measured memory_bytes: 21888
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main() {
    string s;
    cin >> s;
    i64 cnt, t, ans;
    cnt = 0; t = -1, ans = 0;
    for(int i = 0; i < s.length(); ++i){
        if(cnt == 0){
            t = s[i];
            ++cnt;
        }else if(t == s[i]){
            ++cnt;
        }else{
            --cnt;
            ans += 2;
        }
    }
    cout << ans << endl;
}

// n = am + b (a == b)
// n = a(m + 1) 1, 2, 4, 8


Measured memory_bytes: 512
import java.util.Scanner;

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();
        }
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 != 0) {
                continue;
            }
            if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                System.out.println("DENIED");
                return;
            }
        }
        System.out.println("APPROVED");
    }

}


Measured memory_bytes: 23124
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	auto A=in();
	auto B=in<double>();
	ll C = round(B*100);
	ll D = A*C;
	D /= 100ll;
	out(D);
	return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

int main(){
      int a,b,c,d,e,k;
      cin>>a>>b>>c>>d>>e>>k;
      if(e-a>k){
            cout<<":("<<endl;
      }
      else{
            cout<<"Yay!"<<endl;
      }
      return 0;
}

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

const int MOD = 1e9+7;
int add(int a, int b){return ((ll)a + (ll)b)%MOD;}
int mul(int a, int b){return ((ll)a * (ll)b)%MOD;}

void solve(){
  int n; cin >> n;
  vector<int> freq(n, 0);
  for(int i = 1; i < n; i++){
    int a; cin >> a;
    freq[a-1]++;
  }

  for(int i = 0; i < n; i++){
    cout << freq[i] << endl;
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}


Measured memory_bytes: 3952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[3];for (int i = 0; i < 3; i++) a[i] = sc.nextInt();
		int[] l = new int[n];for (int i = 0; i < n; i++) l[i] = sc.nextInt();
		int ans = Integer.MAX_VALUE; int res = 0; int sum = 0;
		String format = "%".concat(String.valueOf(n)).concat("s");
		String s = "";
		OUT:for (int i = 0; i < Math.pow(4, n); i++) {
			s = String.format(format, Integer.toString(i, 4)).replace(" ","0");
			res = 0;
			for (int j = 0; j < 3; j++) {
				sum = 0;
				for (int k = 0; k < s.length(); k++) {
					if((s.charAt(k)-'0')==j) {
						if(sum > 0) res += 10;
						sum += l[k];
					}
				}
				if(sum == 0) {
					continue OUT;
				}else {
					res += Math.abs(sum-a[j]);
				}
			}
			ans = Math.min(ans, res);
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 78800
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


const int M=100005;
int n,k;
vector<int>adj[M];
int ses=1LL;
void dfs(int u,int par)
{
     int cnt=k-1;
     if(par)cnt--;
     for(auto v:adj[u])
     {
         if(v==par)continue;
         ses=gun(ses,cnt);
         cnt--;
     }
     for(auto v:adj[u])
     {
         if(v==par)continue;
         dfs(v,u);
     }
}
 main()

{
    fast
    cin>>n>>k;
    f(i,1,n-1)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    ses=k;
    dfs(1,0);
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n,m;
  cin >> n >> m;
  vector<pair<bool, int >> res(n,mp(false,0));
  rep(i,m){
    int p;
    string s;
    cin >> p >> s;
    --p;
    if(res[p].first) continue;
    else if(s[0]=='W'){
      res[p] = mp(false,res[p].second+1);
    }
    else{
      res[p] = mp(true, res[p].second);
    }
  }
  int ac=0;
  int pena=0;
  rep(i,n){
    if(res[i].first){
      ac++;
      pena+=res[i].second;
    }
  }
  cout << ac << " " << pena << endl;


  
  return 0;
    

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  int taka = (c + b -1) / b, aoki = (a + d -1) / d;
  if (taka <= aoki)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 3620
import sys

antennas = []
for _ in range(5):
    antennas.append(int(input()))
k = int(input())

flag = 1
while(len(antennas) != 1):
    for i in range(len(antennas)-1):
        i += 1
        if antennas[i] - antennas[0] <= k:
            continue
        else:
            flag *= 0
            print(":(")
            sys.exit()
    antennas = antennas[1:]

if flag == 1:
    print('Yay!')


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

const char* goal = " AKIHABARA";
char s[55];

bool subseq(const char* a, const char* b)
{
    int a_nxt = 0;
    for (int i = 0; b[i]; i++) {
        while (a[a_nxt] && a[a_nxt] != b[i]) a_nxt++;
        if (!a[a_nxt]) return false;
        a_nxt++;
    }
    return true;
}

int main()
{
    scanf("%s", s);
    printf("%s",
    (subseq("AKIHABARA", s) && subseq(s, "KIHBR")) ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 3236
//  Created by liszt on 2019/08/04.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,tmp; cin>>n;
    if(n==1){
        cout<<"Yes"<<endl;
        return 0;
    }
    vector<long long> h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    
    long long now=h[0];
    for(int i=1;i<n;i++){
        if(h[i]<now-1){
            cout<<"No"<<endl;
            return 0;
        }else{
            now=max(now,h[i]);
        }
    }
    
    cout<<"Yes"<<endl;
}

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

int main() {
  int k, s;
  int cnt = 0;
  cin >> k >> s;
  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      int c = s - a - b;
      if (c >= 0 && c <= k) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 384
///  author:Kissheart  ///
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );
int n;
char s[MAX];
stack<char>ss;
int main()
{

    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
    {
        if(ss.empty())
        {
            ss.push(s[i]);
            continue;
        }

        if(ss.top()=='0' && s[i]=='1')
        {
            ss.pop();
            continue;
        }

        if(ss.top()=='1' && s[i]=='0')
        {
            ss.pop();
            continue;
        }

        ss.push(s[i]);
    }

    printf("%d\n",n-ss.size());
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int n,a[15]={0},i=0;
  cin>>n;
  while(n){
    a[i++]=(n+1)%3-1;
    n=(n-a[i-1])/3;
  }
  while(i--){
    if(!a[i])cout<<0;
    else if(a[i]>0)cout<<'+';
    else cout<<'-';
  }
  cout<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

class BIT{
public:
	BIT(int _n){
		n = _n;
	}
	void add(int k, int x) {
		for(; k<=n; k += k&-k) bit[k] += x;
	}
	int sum(int k) {
		int res = 0;
		for(; k>0; k -= k&-k) res += bit[k];
		return res;
	}
private:
	int n, bit[1000010];
};

int s, a[200000], b[200000], n;

void compress() {
	sort(b, b + n);
	int t = unique(b, b + n) - b;
	REP(i, n)a[i] = lower_bound(b, b + t, a[i]) - b + 1;
	s = t + 1;
}
int main() {
	cin>>n;
	ll ans = 0;
	REP(i, n) {
		cin>>a[i];
		b[i] = a[i];
	}

	compress();
	BIT bit(n);

	REP(i, n) {
		ans += i - bit.sum(a[i]);
		bit.add(a[i], 1);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5512
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const double pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace Geometry{
    struct Point{
        double x,y,ang;
        Point(double _x=0.0,double _y=0.0) {x=_x;y=_y;}
        void calc() {ang=atan2(y,x);}
    };

    Point operator -(Point a,Point b) {return Point(a.x-b.x,a.y-b.y);}
}

using namespace Geometry;

bool cmp(Point p,Point q) {return p.ang<q.ang;}

Point p[110],nowp[110];
int n,tot;

double solve(int id)
{
    tot=0;
    rep(i,1,n)
        if (i!=id) {nowp[++tot]=p[i]-p[id];nowp[tot].calc();}
    sort(nowp+1,nowp+1+tot,cmp);
    nowp[n].ang=nowp[1].ang+pi*2;
    double mx=0.0;
    rep(i,1,n-1) mx=max(mx,nowp[i+1].ang-nowp[i].ang);
    return max(mx-pi,(double)0);
}

int main()
{
    n=read();
    rep(i,1,n) {p[i].x=read();p[i].y=read();}
    rep(i,1,n) printf("%0.8lf\n",solve(i)/(pi*2));
    return 0;
}


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

ll a[101010],b[101010];

ll modinv(ll a) {
    ll m=Mod;
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    int n,i;
    cin>>n;

    ll kai=1;
    for(i=2;i<=n;i++){
        kai*=i;
        kai%=Mod;
    }

    for(i=1;i<=n;i++){
        a[i]=(kai*modinv(i))%Mod;
    }
    b[1]=a[1];
    for(i=2;i<=n;i++){
        b[i]=(a[i]+b[i-1])%Mod;
    }

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

    ll ans;

    for(i=1;i<=n;i++){
        ans+=s[i]*((Mod+b[i]+b[n+1-i]-b[1])%Mod);
        ans%=Mod;
    }

    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int N,K,Q;
    int A[100003],answer[100003] = {0};
    
    scanf("%d %d %d",&N,&K,&Q);
    for(i = 0;i < Q-1;i++){
        scanf("%d\n",&A[i]);
    }
    scanf("%d",&A[i]);
    
    for(i = 0;i < Q;i++){
        answer[A[i]-1]++;
    }
    
    for(i = 0;i < N;i++){
        if(answer[i] > (Q - K)){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    
    return 0;
}



Measured memory_bytes: 1280
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        System.out.println(solve(A, B, C, D));

        sc.close();
    }

    static int solve(int A, int B, int C, int D) {
        return Math.max(A * B, C * D);
    }
}

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;

double graph[101][101];
double a[101][101];
int q[101];

typedef vector<double> vectorDBL;
typedef vector<vectorDBL> matrixDBL;
const double eps = 1e-9;
vectorDBL gauss_jordan(const matrixDBL& A, const vectorDBL b)
{
  int n = A.size();
  // ?????§?????°??????  
  matrixDBL Ab(n, vectorDBL(n + 1));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) Ab[i][j] = A[i][j];
  }
  for(int i = 0; i < n; i++) Ab[i][n] = b[i];

  // ?§£???
  for(int i = 0; i < n; i++) {
    int pivot = i;
    for(int j = i; j < n; j++) {
      if(abs(Ab[pivot][i]) < abs(Ab[j][i])) pivot = j;
    }
    swap(Ab[i], Ab[pivot]);    
    if(abs(Ab[i][i]) < eps) return vectorDBL();
    // ?????????????????°??§??????
    for(int j = i+1; j < n+1; j++) Ab[i][j] /= Ab[i][i];
    // ????????????
    for(int j = 0; j < n; j++) {
      if(i != j) {
	for(int k = i+1; k < n+1; k++) Ab[j][k] -= Ab[j][i] * Ab[i][k];
      }
    }
  }
  
  // ?§£
  vectorDBL x(n);
  for(int i = 0; i < n; i++) x[i] = Ab[i][n];
  return x;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, s, t;
  while(cin >> n >> s >> t, n) {
    s--, t--;
    rep(i, n) cin >> q[i];
    fill(graph[0], graph[101], inf);
    rep(i, n) rep(j, n) {
      cin >> a[i][j];
      if(a[i][j] == 0) a[i][j] = inf;
      graph[i][j] = (i == j ? 0 : a[i][j]);
    }
    rep(i, n) rep(j, n) rep(k, n) {
      graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
    }
    
    if(graph[s][t] == inf) {
      cout << "impossible" << endl;
      return 0;
    }

    matrixDBL A(n, vectorDBL(n, 0));
    vectorDBL b(n, 0);

    rep(i, n) {
      double deg = 0, c = 0;
      if(i == t) { // theater : expected x_t = 0
	deg = 1, c = 0;
      } else if(q[i] == 1) { // sign : expected x_i = x_to + a[i][to]
	rep(j, n) {
	  if(graph[i][t] == a[i][j] + graph[j][t]) A[i][j] = -1, c += a[i][j], deg++;
	}
      } else { // not : expected x_i = ?£(x_j + a[i][j])/m
	rep(j, n) {
	  if(a[i][j] != inf) A[i][j] = -1, c += a[i][j], deg++;  
	}
      }
      A[i][i] = deg, b[i] = c;      
    }

    auto x = gauss_jordan(A, b);
    cout << x[s] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3516
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }

            HashMap<Integer, Integer> numberToCount = new HashMap<>();
            for (int i = 0; i < N; i++) {
                Integer count = numberToCount.get(A[i]);
                numberToCount.put(A[i], 1 + (count == null ? 0 : count.intValue()));
            }

            int count = 0;
            for (Integer number : numberToCount.keySet()) {
                if (numberToCount.get(number).intValue() % 2 == 1) {
                    count++;
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 54556
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

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

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n, q;
    cin >> n >> q;
    using T = tuple<int, int, int>;
    vector<T> sections(n);
    rep(i, n) {
        int s, t, x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        sections[i] = T(x, s, t);
    }
    sort(sections.begin(), sections.end());
    
    set<P> st;
    rep(i, q) {
        int d;
        cin >> d;
        st.insert(P(d, i));
    }
    
    vector<int> dists(q, -1);
    for (T sec: sections) {
        int x, s, t;
        tie(x, s, t) = sec;
        for (auto ite = st.lower_bound(P(s, -1)); ite != st.end() && ite->first < t;) {
            dists[ite->second] = x;
            st.erase(ite++);
        }
    }
    print(dists, "\n");
}

Measured memory_bytes: 14336
s=input()
a=0
m={}
d=1
for i in range(len(s)):
  b=int(s[len(s)-1-i])*d+a
  b=b%2019
  a=b
  d=d*10%2019
  if b in m:
    m[b]+=1
  else:
    m[b]=1
if 0 in m:
  sum=m[0]
else:
  sum=0
for i in m:
  sum+=m[i]*(m[i]-1)/2
print(int(sum))



Measured memory_bytes: 9380
#include <stdio.h>

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

  while(1){
    scanf("%d", &x[n]);
    if(x[n] == 0)
      break;
    n++;
  }

  for(i = 0; i < n; i++)
    printf("Case %d: %d\n", i+1, x[i]);

  return 0;
}



Measured memory_bytes: 2052