akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 

using namespace std;

int main()
{
	double a, b, c;
	cin >> a >> b >> c;
	double d,e;
	double S, L, h;
	
	double pi;
	pi = 3.1415926535;
    e = c / 180*pi;

	d = sqrt(a*a + b * b - 2 * a*b*cos(e));
	h = b*sin(e);
	S = a * h / 2;
	L = a + b + d;

//

    cout<<setprecision(20)<<S<<" "<<L<<" "<<h<<endl;
	return 0;
}


Measured memory_bytes: 3520
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        long[] cnt = new long[26];
        int[] cnt2 = new int[26];
        string MARCH = "MARCH";
        foreach (var c in MARCH)
        {
            cnt2[c - 'A'] = 1;
        }

        for (int i = 0; i < N; i++)
        {
            string s = cin.next();
            cnt[s[0] - 'A']++;
        }

        for (int i = 0; i < 26; i++)
        {
            cnt[i] *= cnt2[i];
        }


        long ans = 0;
        for (int i = 0; i < 26; i++)
        {
            for (int j = i + 1; j < 26; j++)
            {
                for (int k = j + 1; k < 26; k++)
                {
                    ans += cnt[i] * cnt[j] * cnt[k];
                }
            }
        }
        Console.WriteLine(ans);
    }
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 17232
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var X = F;
		WriteLine(X == 3 || X == 5 || X == 7 ? "YES" : "NO");
	}
}


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

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }

        static void MainStream()
        {
            int K = int.Parse(Console.ReadLine());

            if(K%2==1)
            {
                Console.WriteLine((K / 2) * ((K / 2) + 1));
            }
            else
            {
                Console.WriteLine((K / 2) * (K / 2));
            }
        }



    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll dp[505050];
int N,M;
const ll mo=1000000007;
const int NUM_=600001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];

ll comb(ll N_, ll C_) {
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;

	inv[1]=fact[0]=factr[0]=1;
	for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
	for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;

	cin>>N>>M;
	ll ret=0;
	FOR(i,N+1) {
		dp[i]=comb(M,i)*comb(N,i)%mo*fact[i]%mo*fact[M-i]%mo*fact[M-i]%mo*factr[M-N]%mo*factr[M-N]%mo;
		if(i%2) {
			ret-=dp[i];
		}
		else {
			ret+=dp[i];
		}
	}

	cout<<(ret%mo+mo)%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 21448
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;
int n,m,q;
vi a,b,c,d;
int ans = 0;
void solve(vi v){
	if(v.size()==n){
		int sum = 0;
		for(int i = 0; i < q; i++){
			if(v[b[i]] - v[a[i]] == c[i]){
				sum+=d[i];
			}
		}
		ans = max(ans,sum);
	}
	else{
		int st = 1;
		if(v.size())st = v.back();
		for(int i = st; i <= m; i++){
			v.push_back(i);
			solve(v);
			v.pop_back();
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	for(int i = 0; i < q; i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;
		b[i]--;
	}
	solve(vi());
	cout<<ans<<nl;
	return 0;
}



Measured memory_bytes: 3664
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

int ds(int a) {
  int res=0;
  while (a > 0) {
    res += a % 10;
    a /= 10;
  }
  return res;
}

int ds(int a, int b) {
  return ds(a)+ds(b);
}

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

  int res=1e9;
  for (int i=1; i<N; ++i) 
    res = std::min(res, ds(i, N-i));

  printf("%d\n", res);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int N, M;
MAT<int> g;
int treesize(VEC<bool> &used, int root) {
  if (used[root])
    return 0;
  else {
    cerr << root << endl;
    int sum = 1;
    used[root] = 1;
    REP(i, 0, N) {
      if (g[root][i] > 0 && !used[i]) {
        sum += treesize(used, i);
      }
    }
    return sum;
  }
}

int main() {
  cin >> N >> M;
  g = MATINIT(int, N, N, 0);
  VEC<pair<int, int>> edge(M);
  REP(i, 0, M) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a][b] = 1;
    g[b][a] = 1;
    edge[i] = {a, b};
  }
  VEC<bool> used(N, 0);
  int originalSize = treesize(used, 0);
  int cnt = 0;

  REP(i, 0, M) {
    int a = edge[i].first;
    int b = edge[i].second;
    g[a][b] = g[b][a] = 0;
    REP(j, 0, N) used[j] = 0;
    DUMP(a, b);
    int siz = treesize(used, 0);
    if (siz != originalSize) {
      ++cnt;
    }
    g[a][b] = g[b][a] = 1;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define LOOP 1

int calculate(int, int, char);

int main(void) 
{
	int dst, answer;
	char op = '\0';

	scanf("%d\n", &answer);

	while (LOOP) {
		scanf("\n%c", &op);

		if (op == '=') 
			break;
		else {
			scanf("\n%d", &dst);
			answer = calculate(answer, dst, op);
		}
	}
	printf("%d\n", answer);

	return 0;
}

int calculate (int src, int dst, char op) 
{
	int answer;

	switch (op) {
	case '+':
		answer = src + dst;
		break;
	case '-':
		answer = src - dst;
		break;
	case '*':
		answer = src * dst;
		break;
	case '/':
		answer = src / dst;
		break;
	}

	return answer;
}

Measured memory_bytes: 596
N = int(input())

A = [int(x) for x in input().split()]

B = [int(x) for x in input().split()]

i = 0
total = 0
C = [A[0]]
while i < N:
  C.append(A[i+1])
  if C[0] >= B[i]:
    total += (C[0] - B[i])
    del C[0]
  else:
    if sum(C) - B[i] >= 0:
      tmp = sum(C) - B[i]
    else:
      tmp = 0
    C.clear()
    C.append(tmp)
  i += 1 
    
print(sum(A) - (total+sum(C))) 

Measured memory_bytes: 19156
n, q = map(int, input().split())
s = input()
c = [0]
for i in range(len(s)-1):
  if s[i] == "A" and s[i+1] == "C":
    c.append(c[-1]+1)
  else:
    c.append(c[-1])
    
for i in range(q):
  l, r = map(int, input().split())
  print(c[r-1] - c[l-1])

Measured memory_bytes: 6100
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

  
signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n;
  cin >> n;
  vector<int> h(n);
  REP(i,n) cin >> h[i];
  
  int ans = 0;
  int t = 0;
  REP(i, n - 1){
    if(h[i] >= h[i + 1]){
      t++;
    }
    else{
      ans = max(t, ans);
      t = 0;
    }
  }
  ans = max(t, ans);

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s, t; cin >> s >> t; 
    int res = 0;
    for(int i=0; i<s.size()-t.size()+1; ++i){
        int cnt = 0;
        for(int j=0; j<t.size(); ++j){
            if(s[i+j]==t[j]){cnt++;}
        } 
        res = max(res, cnt); 
    }
    res = t.size() - res;
    cout << res << endl;
    return 0;
}

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

typedef struct{
  int x,y;
} point;

void shift_o(point ep, point *line, int m){ // ????????????????????????????????????
  rep(i,m){
    line[i].x -= ep.x;
    line[i].y -= ep.y;
  }
}

void round(point *line, int m){
  rep(i,m){
    point tmp = line[i];
    line[i].x = -(tmp.y);
    line[i].y = tmp.x;
  }
}

bool IsSame(point *base, point *line, int m){
  rep(i,m){
    if(line[i].x != base[i].x || line[i].y != base[i].y)
      return false;
  }
  return true;
}

void CopyLine(const point *original, point *copy, int m){
  while(m-->0){
    *copy++ = *original++;
  }
}

void revline(point *line,int m){ 
  point tmp;
  rep(i,m/2){
    tmp=line[i];
    line[i]=line[m-i-1];
    line[m-i-1]=tmp;
  }
}

void Plus5(){
  rep(i,5){
    putchar('+');
  }
  putchar('\n');
}

int main(){
  for(;;){
    int n;
    scanf("%d",&n);
    if(!n) break;

    //0??????????????????
    int m0;
    point base[10];
    scanf("%d",&m0);
    rep(i,m0){
      scanf("%d %d",&base[i].x,&base[i].y);
    }

    //1????????\???????????????
    int m[50];
    point line[50][10];
    rep(i,n){
      scanf("%d",&m[i]);
      rep(j,m[i]){
	scanf("%d %d",&line[i][j].x,&line[i][j].y);
      }
    }

    // base??????????????????
    point ep1=base[0] ,ep2=base[m0-1];

    point copy[10];
    CopyLine(base,copy,m0);

    shift_o(ep1,base,m0);
    shift_o(ep2,copy,m0);

    rep(i,n){
      if(m[i]==m0){
	shift_o(line[i][0], line[i], m0);
	if(IsSame(base,line[i],m0)||IsSame(copy,line[i],m0)){
	  printf("%d\n",i+1);
	  continue;
	}
	revline(line[i], m0);
	shift_o(line[i][0], line[i], m0);
	if(IsSame(base,line[i],m0)||IsSame(copy,line[i],m0)){
	  printf("%d\n",i+1);
	  continue;
	}
	revline(line[i], m0);
	shift_o(line[i][0], line[i], m0);
	rep(j,3){
	  round(line[i],m0);
	  if(IsSame(base,line[i],m0)||IsSame(copy,line[i],m0)){
	    printf("%d\n",i+1);
	    break;
	  }
	  revline(line[i], m0);
	  shift_o(line[i][0], line[i], m0);
	  if(IsSame(base,line[i],m0)||IsSame(copy,line[i],m0)){
	    printf("%d\n",i+1);
	    break;
	  }
	}
      }
    }  
    Plus5();
  } 
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
void solve()
{
	long long A,B,C,D;
	scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
	long long K=(max(A,B)+min(A,B))/(min(A,B)+1);
	long long l=-1,r=B+1;
	while(l+1<r){
		long long mid=(l+r)>>1;
		long long AA=A-mid*K;
		long long BB=B-mid;
		if(AA<0||BB<0||BB>AA*K)r=mid;
		else l=mid;
	}
	long long X=l*(K+1);A-=l*K;B-=l;
	long long Y=X+(A*K-B)/K+1;A-=(A*K-B)/K+1;
	long long Z=Y+B-A*K;
	for(int i=C;i<=D;i++)
		if(i<=X){
			if(i%(K+1))printf("A");
			else printf("B");
		}
		else if(i<=Y)printf("A");
		else if(i<=Z)printf("B");
		else{
			if((i-Z)%(K+1)==1)printf("A");
			else printf("B");
		}
	printf("\n");
	return ;
}
int main()
{
	int q;
	scanf("%d",&q);
	while(q--)
		solve();
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i = 0 ; i < s.length() ; i++) {
			if((i + 1) % 2 == 0) {
			if(s.charAt(i) == 'R') {
				System.out.println("No");
				return;
				}
				}
			else {
				if(s.charAt(i) == 'L') {
					System.out.println("No");
					return;
					}
					}
			}

		sc.close();
		System.out.println("Yes");

	}
}



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

using namespace std;

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

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

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

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, W;
	while ( cin >> N >> W, N || W ) {
		vector<int> v(N); cin >> v;
		sort(ALL(v));
		int M = v[N-1]/W+1;
		vector<int> cnt(M);
		REP(i,N) {
			cnt[v[i]/W]++;
		}
		int base = 0;
		REP(i,M) {
			base = max(base, cnt[i]);
		}
		ld ans = 0.01;
		REP(i,M) {
			ans += (ld)(M-i-1)/(M-1) * cnt[i]/base;
		}
		cout << fixed << setprecision(10) << ans << endl;
	}
}

Measured memory_bytes: 3148
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
// #define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<pair<double, double>> xys(n); cin >> xys;
    // prints(xys);
    for(int i = 0; i < n; i++){
        double rmin = -100, rmax = 100,
               rmin2 = -100, rmax2 = 100;
        for(int j = 0; j < n; j++){
            if(i == j){ continue; }
            double r = atan2(-(xys[i].first - xys[j].first), (xys[i].second - xys[j].second));
            double r2 = r + M_PI;
            printd(r, r2);
            if(r < 0){
                rmin2 = max(rmin2, r);
                rmax2 = min(rmax2, r2);
            }else{
                rmin = max(rmin, r);
                rmax = min(rmax, r2);
            }
        }
        printd(rmax, rmin);
        printd(rmax2, rmin2);
        double r3 =
            rmin == -100 ? rmax2 - rmin2 :
            rmin2 == -100 ? rmax - rmin :
            max(.0, rmax2 - rmin) + max(.0, rmax - (rmin2 + 2 * M_PI));
        r3 = r3 > M_PI ? 2 * M_PI - r3 : r3;
        cout << fixed << setprecision(10) << max(0., r3 / 2 / M_PI) << endl;
    }
}


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

int main(){
            
    int N,n,count;
    vector<int> v;
    cin>>N;
    for(int i = 0;i<N;i++){
	cin>>n;
	v.push_back(n);
    }
    sort(v.begin(),v.end());
    n = -1;
    for(int i = N-1;i>=0;i--){
	if(n == -1 && v[i]!= 0){
	    n = v[i];
	    ++count;
	}
	if(n != v[i] && v[i]!= 0){
	    n = v[i];
	    ++count;
	}
    }
    cout<<count;    

}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n, m;
int x[5000];
int y[5000];
vector<int> vx;
vector<int> vy;
int f[5000][5000];

void compress(){
	rep(i, n){
		vx.push_back(x[i]);
		vy.push_back(y[i]);
	}
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	vx.erase(unique(vx.begin(), vx.end()), vx.end());
	vy.erase(unique(vy.begin(), vy.end()), vy.end());
	rep(i, n){
		x[i] = lower_bound(vx.begin(), vx.end(), x[i]) - vx.begin();
		y[i] = lower_bound(vy.begin(), vy.end(), y[i]) - vy.begin();
	}
}

void accumulate(){
	rep(i, n){
		++f[x[i]][y[i]];
	}
	rep(i, vx.size()){
		rep(j, vy.size() - 1){
			f[i][j + 1] += f[i][j];
		}
	}
	rep(i, vx.size() - 1){
		rep(j, vy.size()){
			f[i + 1][j] += f[i][j];
		}
	}
}

void transform(int&a, int& b, int& c, int& d){
	a = lower_bound(vx.begin(), vx.end(), a) - vx.begin();
	b = lower_bound(vy.begin(), vy.end(), b) - vy.begin();
	c = upper_bound(vx.begin(), vx.end(), c) - vx.begin() - 1;
	d = upper_bound(vy.begin(), vy.end(), d) - vy.begin() - 1;
}

int access(int i, int j){
	return i >= 0 && j >= 0 ? f[i][j] : 0;
}

int main(){
	scanf("%d%d", &n, &m);
	rep(i, n){
		scanf("%d%d", &x[i], &y[i]);
	}
	compress();
	accumulate();
	rep(i, m){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		transform(a, b ,c, d);
		if(a <= c && b <= d){
			printf("%d\n", access(c, d) + access(a - 1, b - 1) - access(c, b - 1) - access(a - 1, d));
		}
		else{
			puts("0");
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
	int N;cin>>N;
	int x[N][2];
	
	for(int i=0;i<N;i++){
		for(int j=0;j<2;j++){
			cin>>x[i][j];
		}
	}
	
	int res=0;
	int a[N]={0};
	for(int i=0;i<N;i++){
		if(x[i][0]==x[i][1]){
			a[i]=1;
			if(i>0){
				a[i]+=a[i-1];
			}
		}
		res=max(res,a[i]);
	}
	
	if(res>2){
		cout<<"Yes";
	} else{
		cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int A, B, C; cin >> A >> B >> C;
  cout << (2 * B == A + C ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line printf("-----------------------------\n")
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int  main()
{
    int n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    if(str[k-1]>='A' and str[k-1]<='Z')  str[k-1]=str[k-1]+32;
    cout<<str<<endl;
}


Measured memory_bytes: 256
object Main {
    import scala.language.implicitConversions
    import scala.language.reflectiveCalls
    type P = (Double, Double)
    implicit def toRichPoint(p: P) = new{ 
        def +(o: P) = (p._1 + o._1, p._2 + o._2)
        def -(o: P) = (p._1 - o._1, p._2 - o._2)
        def /(n: Double) = (p._1 / n, p._2 / n)
        def *(n: Double) = (p._1 * n, p._2 * n)
        val d = math.Pi/3
        def rot = (p._1 * math.cos(d) - p._2 * math.sin(d), p._1 * math.sin(d) + p._2 * math.cos(d))
    }
    def koch(p1: P, p2: P, n: Int): Unit = {
        if (n == 0) println(p1._1 + " " + p1._2)
        else {
            val s = (p2 - p1) / 3 + p1
            val t = (p2 - p1) * 2 / 3 + p1
            val u = s + (t - s).rot
            koch(p1, s, n-1)
            koch(s, u, n-1)
            koch(u, t, n-1)
            koch(t, p2, n-1)
        }
    }
    def main(args: Array[String]) = {
        val in = io.StdIn.readInt
        val p1 = (0.0, 0.0)
        val p2 = (100.0, 0.0)
        koch(p1, p2, in)
        println(p2._1 + " " + p2._2)
    }
}

Measured memory_bytes: 51184
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
using namespace std;

int INF=1e9;

int main(void){
    long long n;
    cin>>n;
    long long a[5]={};
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]=='M')a[0]++;
        else if(s[0]=='A')a[1]++;
        else if(s[0]=='R')a[2]++;
        else if(s[0]=='C')a[3]++;
        else if(s[0]=='H')a[4]++;
    }
    long long ans=0;
    ans=a[0]*a[1]*a[2]+a[0]*a[1]*a[3]+a[0]*a[1]*a[4]+a[0]*a[2]*a[3]+a[0]*a[2]*a[4]+a[0]*a[3]*a[4]+a[1]*a[2]*a[3]+a[1]*a[2]*a[4]+a[1]*a[3]*a[4]+a[2]*a[3]*a[4];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left as bl
N = int(input())
A = [int(input()) for i in range(N)]

de = deque([])
de.append(A[0])
for a in A[1:]:
    ind = bl(de, a)
    if ind == 0:
        de.appendleft(a)
    else:
        de[ind-1] = a

print(len(de))

Measured memory_bytes: 8824
use std::cmp::min;
use std::fmt;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

struct InputScanner<R: BufRead> {
    reader: R,
    buf: Vec<u8>, // Should never be empty
    pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}

impl<R: BufRead> InputScanner<R> {
    fn new(reader: R, capacity: usize) -> Self {
        InputScanner {
            reader: reader,
            buf: Vec::with_capacity(capacity),
            pos: 0,
        }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        if self.buf.is_empty() {
            self._read_next_line();
        }
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) => self.pos += 1,
                (b'\n', false) => self._read_next_line(),
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    #[inline]
    fn _read_next_line(&mut self) {
        self.pos = 0;
        self.buf.clear();
        if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
            panic!("Reached EOF");
        }
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut scanner = InputScanner::new(stdin.lock(), 1200000);
    let n: i32 = scanner.next();
    let a: Vec<i32> = (0..n).map(|_| scanner.next()).collect();
    let b: Vec<i32> = (0..n).map(|_| scanner.next()).collect();

    let mut c: Vec<i32> = a.iter().zip(b.iter()).map(|(x, y)| x - y).collect();
    c.sort();
    let mut p = 0;
    let mut q = c.len() - 1;
    let mut p_moved = 0;
    let mut q_moved = 0;
    while p < q && c[p] < 0 && c[q] > 0 {
        let mv = min(-c[p], c[q]);
        c[p] += mv;
        c[q] -= mv;
        if mv > 0 {
            p_moved = p + 1;
            q_moved = c.len() - q;
        }
        if c[q] == 0 {
            q -= 1;
        }
        if c[p] == 0 {
            p += 1;
        }
    }
    let res: i32 = if c[p] < 0 {
        -1
    } else {
        (q_moved + p_moved) as i32
    };
    println!("{}", res)
}


Measured memory_bytes: 6396
#include<iostream>
#include<algorithm>
typedef long long lint;
using namespace std;

int main()
{
	lint N,K;
	lint a,b;
	lint amin=1e9,amax=0;
	lint array[100010]={};
	lint sum=0;
	
	cin >> N >> K;
	for(lint i=0;i<N;i++)
	{
		cin >> a >> b;
		array[a]+=b;
		amin=min(amin,a);
		amax=max(amax,a);
	}
	
	for(lint i=amin;i<=amax;i++)
	{
		sum+=array[i];
		if(sum>=K)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!

class rest {
public:
	string S;
	int P;
	int Num;
public:
	rest(string s, int p, int num) {
		S = s;
		P = p;
		Num = num;
	}
	bool operator<(const rest &another) const
	{
		if (S != another.S)return S < another.S;
		return P > another.P;

	};
};

int imos[1000000];

signed main() {
	int N;
	cin >> N;
	cout << 180 * (N - 2) << endl;


	return 0;
}

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

int main(){
  using lint = long long;
  lint X;
  cin >> X;
  
  lint cnt = 0;
  lint yen = 100;
  
  while(X > yen){
    yen += yen/100;
    cnt++;
    // cout << yen << cnt << endl;
    
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3636
def main():
    n = int(input())
    aa = list(map(int, input().split()))
    pairs = []
    c = 0
    i = j = 0
    while j < n:
        a = aa[j]
        if c & a:
            pairs.append([i, j])
            for ii in range(i, j):
                c ^= aa[ii]
                if c & a == 0:
                    i = ii + 1
                    break
        else:
            c |= a
            j += 1
    pairs.append([i, n])
    end = 0
    ans = 0
    for i, j in pairs:
        d = j - i
        ans += d * (d + 1) // 2
        if i < end:
            d = end - i
            ans -= d * (d + 1) // 2
        end = j
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 99916
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N,M;
	int T[101];
	cin>>N;
	rep1(i,N)cin>>T[i];
	cin>>M;
	int P[101],X[101];
	rep1(i,M)cin>>P[i]>>X[i];
	int SUM=0;
	rep1(i,N)SUM+=T[i];
	rep1(i,M){
		int dSUM=SUM-T[P[i]]+X[i];
		cout<<dSUM<<endl;
	}
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	nStr := read()
	nInt, _ := strconv.Atoi(nStr)
	if nInt < 10 {
		fmt.Println(nInt)
		return
	}
	nInt += 1
	nStr = strconv.Itoa(nInt)
	nSlice := strings.Split(nStr, "")
	topStr := nSlice[0]
	top, _ := strconv.Atoi(topStr)
	top -= 1
	if top == 0 {
		topStr = ""
	} else {
		topStr = strconv.Itoa(top)
	}
	for i := 0; i < len(nSlice)-1; i++ {
		topStr += "9"
	}
	output := strings.Split(topStr, "")
	sum := 0
	for _, valStr := range output {
		val, _ := strconv.Atoi(valStr)
		sum += val
	}
	fmt.Println(sum)
}


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

const int DIM = 5e2 + 5;

int prm[DIM * DIM];
pair<int, int> arr[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    bool ok = true;
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i].first;
        arr[i].second = i;
    }
    
    sort( arr + 1, arr + n + 1 );
    
    for( int i = 1, j = 1; i <= n; i ++ ) {
        for( int k = 1; k < arr[i].second; k ++ ) {
            while( j <= n * n && prm[j] != 0 )
                j ++;
            
            if( j >= arr[i].first )
                ok = false;
            else
                prm[j] = arr[i].second;
        }
        
        prm[arr[i].first] = arr[i].second;
    }
    
    for( int i = n, j = n * n; i >= 1; i -- ) {
        for( int k = n; k > arr[i].second; k -- ) {
            while( j >= 1 && prm[j] != 0 )
                j --;
            
            if( j <= arr[i].first )
                ok = false;
            else
                prm[j] = arr[i].second;
        }
        
        prm[arr[i].first] = arr[i].second;
    }
    
    if( ok == false )
        cout << "No\n";
    else {
        cout << "Yes\n";
        
        for( int i = 1; i <= n * n; i ++ )
            cout << prm[i] << " ";
    }
    
    return 0;
}

Measured memory_bytes: 2176
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int n;
    cin >> n;

    cout << 800 * n - (n / 15) * 200 << endl;

    return 0;
}

Measured memory_bytes: 764
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n,k=parseMap(split(readline()))
    ans=0.0
    for i in 1:n
        if i<k
            ans+=1/(n*(2^trunc(Int,ceil(log2(k/i)))))
        else
            ans+=1/n
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 112464
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;
	long long n = s.length(), i, j, k, ans;
	vector<long long> a(n + 1, -1);

	if (s[0] == '<') {
		a[0] = 0;
		for (j = 0; (j < n) && (s[j] == '<'); j++) a[j + 1] = a[j] + 1;
	}
	if (s[n - 1] == '>') {
		a[n] = 0;
		for (j = n - 1; (j >= 0) && (s[j] == '>'); j--) a[j] = a[j + 1] + 1;
	}
	for (i = 0; i < n - 1; i++) {
		if ((s[i] == '>') && (s[i + 1] == '<')) {
			a[i + 1] = 0;
			for (j = i; (j >= 0) && (s[j] == '>'); j--) a[j] = a[j + 1] + 1;
			for (j = i + 2; (j <= n) && (s[j - 1] == '<'); j++) a[j] = a[j - 1] + 1;
		}
	}
	for (i = 0; i < n - 1; i++) {
		if ((s[i] == '<') && (s[i + 1] == '>')) a[i + 1] = 1 + max(a[i], a[i + 2]);
	}
	ans = 0;
	for (auto p : a) ans += p;
	cout << ans << "\n";

	return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

ll gcd(ll a, ll b){
    if(b!=0){
        return gcd(b,a%b);
    }
    return a;
}

int main(){
    ll n,x;
    ll a[100010];
    cin >> n >> x;
    rep(i,n){
        cin >> a[i];
        a[i]=abs(a[i]-x);
    }
    ll ans=a[0];
    rep(i,n-1){
        ans=gcd(ans,a[i+1]);
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,t;
   cin>>a>>b>>c;
   t=a*b;
   if(t>c)
    cout<<c<<"\n";
   else if(t<=c)
   {
       cout<<t<<"\n";
   }


return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,A[100000];
    int i,j;
    int x,tmp;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
	scanf("%d",&A[i]);
    }

    i=-1;
    x=A[n-1];
    for(j=0;j<n-1;j++){
	if(A[j]<=x){
	    i++;
	    tmp=A[i];
	    A[i]=A[j];
	    A[j]=tmp;
	}
    }
    tmp=A[i+1];
    A[i+1]=A[n-1];
    A[n-1]=tmp;

    for(j=0;j<n;j++){
	if(j) printf(" ");
	if(j==i+1) printf("[%d]",A[j]);
	else printf("%d",A[j]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

namespace math { namespace integer {

template<class value_type> value_type mod_mul(value_type x, value_type k, ll m) { if(k == 0) { return 0; } if(k % 2 == 0) { return mod_mul((x+x) % m, k/2, m); } else { return (x + mod_mul(x, k-1, m)) % m; } }
template<class value_type> value_type mod_pow(value_type x, value_type n, ll mod) { if(n == 0) { return 1; } if(n % 2 == 0) { return mod_pow(mod_mul(x, x, mod) % mod, n / 2, mod); } else { return mod_mul(x, mod_pow(x, n - 1, mod), mod); } }
template<class value_type> value_type extgcd(value_type a, value_type b, value_type& x, value_type& y) { value_type d = a; if(b != 0) { d = extgcd(b, a%b, y, x); y -= (a / b) * x;} else { x = 1, y = 0; } return d; }
template<class value_type> value_type mod_inverse(value_type x, ll mod) { return mod_pow(x, value_type(mod-2), mod); /* use fermat */ }
template<class value_type> value_type mod_inverse_composite_num_mod(value_type a, ll mod) { value_type x, y; extgcd(a, mod, x, y); return (mod + x % mod) % mod; }

}}
using namespace math::integer;
template<class T>
T lcm(T x, T y) {
  return x / __gcd(x, y) * y;
}

int main() {

  for(int A, B, d; cin >> A >> B >> d && (A|B|d);) {
    int G = __gcd(__gcd(A, B), d);
    A /= G, B /= G, d /= G;
    ll ans = 1e18, axby = 1e18; int tx = -1, ty = -1;
    for(int sgn=-1; sgn<2; sgn+=2) {
      int a = sgn * A, b = -sgn * B;
      int x, y; int g = extgcd(a, b, x, y);
      x *= d / g, y *= d / g;
      ll L = lcm(a, b);
      rep(_, d) {
        if(x >= 0 || y >= 0) {
          if(minimize(ans, abs(x) + abs(y))) {
            axby = a * x + b * y;
            tx = x, ty = y;
          }
          else if(ans == abs(x) + abs(y)) {
            if(minimize(axby, (ll)a * x + b * y)) {
              tx = x, ty = y;
            }
          }
        }
        x += L / abs(a);
        y += L / abs(b);
      }
    }
    cout << abs(tx) << " " << abs(ty) << endl;

  }
  
  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int n; cin >> n;
    vector<string> s(n);
    vector<string> copy;
    int ans=0;
    rep(i,n){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    rep(i,n){
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7528
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


int main(){
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  
  rep(i,n) cin >> h[i];
  
  int ans;
  double tmp = 1 << 30;
  
  rep(i,n){
    if (tmp > abs(a - (t - h[i] * 0.006))){  
      tmp = abs(a - (t - h[i] * 0.006));
      ans = i + 1;
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int A[3][3];
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> A[i][j];
		}
	}
	int n;
	cin >> n;
	int b[10];
	for (int h = 0; h < n; h++)
	{
		cin >> b[h];
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (b[h] == A[i][j])
					A[i][j] = -1;
			}
		}
	}
	for (int i = 0; i < 3; i++)
	{
		if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1)
		{
			cout << "Yes" << endl;
			return 0;
		}
		if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1)
	{
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1)
	{
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = len(s) - r - g
ans = r*g*b

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

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if( A > B || ( N == 1 && A != B ) ){
    cout << 0 << endl;
    return 0;
  }else if( A == B || N == 2 ){
    cout << 1 << endl;
    return 0;
  }
  
  int mini = (N-1)*A+B;
  int big = A+(N-1)*B;
  cout << big - mini + 1 << endl;
  
     
      
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
 
	vector<int> waterPatterns;
	for (int i = 0; i <= 30; ++i) {
		if (A * i * 100 > F) {
			continue;
		}
		for (int j = 0; j <= 30; ++j) {
			int amount = A * i * 100 + B * j * 100;
			if (amount == 0) {
				continue;
			}
			if (amount > F) {
				continue;
			}
			bool found = false;
			for (int k = 0; k < waterPatterns.size(); ++k) {
				if (waterPatterns[k] == amount) {
					found = true;
					break;
				}
			}
			if (!found) {
				waterPatterns.push_back(amount);
			}
		}
	}
 
 
	int bestWater = 0;
	int bestSuger = 0;
	double bestNoudo = 0.0;
	for (int k = 0; k < waterPatterns.size(); ++k) {
		vector<int> sugerPatterns;
		for (int i = 0; i <= 3000; ++i) {
			if (C * i + waterPatterns[k] > F) {
				continue;
			}
			for (int j = 0; j <= 3000; ++j) {
				int sugerAmount = C * i + D * j;
				int totalAmount = sugerAmount + waterPatterns[k];
				if (totalAmount == 0) {
					continue;
				}
				if (totalAmount > F) {
					continue;
				}
				double wariai = (double)sugerAmount / waterPatterns[k] * 100;
				if (wariai > E + 0.00000001) {
					continue;
				}
				double noudo = (double)sugerAmount * 100.0 / totalAmount;
				if (noudo < bestNoudo) {
					continue;
				}
				bestWater = waterPatterns[k];
				bestSuger = sugerAmount;
				bestNoudo = noudo;
			}
		}
	}
 
	cout << (bestWater + bestSuger) << " " << bestSuger << endl;
	cerr << (bestWater + bestSuger) << " " << bestSuger << endl;
	getchar();
	getchar();
 
	return 0;
}

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

long long a[50];

int main(){
  long long k;
  cin >> k;
  long long u = k % 50;
  long long v = k / 50 - u;
  for (long long i = 0; i < 50; i++) {
    a[i] = 49 + v;
    if (i < u) a[i] += 50;
  }
  printf("50\n");
  for (int i = 0; i < 50; i++) {
    if (i == 0) printf("%lld", a[i]);
    else printf(" %lld", a[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
using namespace std;
const int N=100050;
const int inf=1e9+7;
int dist[N];
bool was[N];
int main()
{
	int n,i;
	scanf("%i",&n);
	for(i=0;i<N;i++) dist[i]=inf,was[i]=0;
	dist[n]=0;was[n]=1;
	queue<int> q;
	q.push(n);
	while(q.size())
	{
		int x=q.front();
		q.pop();
		if(x-1>=0 && !was[x-1]) q.push(x-1),was[x-1]=1,dist[x-1]=dist[x]+1;
		//if(x+1<n && !was[x+1]) q.push(x+1),was[x+1]=1,dist[x+1]=dist[x]+1;
		for(i=6;i<=x;i*=6)
		{
			if(x-i>=0 && !was[x-i]) q.push(x-i),was[x-i]=1,dist[x-i]=dist[x]+1;
			//if(x+i<n && !was[x+i]) q.push(x+i),was[x+i]=1,dist[x+i]=dist[x]+1;
		}
		for(i=9;i<=x;i*=9)
		{
			if(x-i>=0 && !was[x-i]) q.push(x-i),was[x-i]=1,dist[x-i]=dist[x]+1;
			//if(x+i<n && !was[x+i]) q.push(x+i),was[x+i]=1,dist[x+i]=dist[x]+1;
		}
	}
	printf("%i\n",dist[0]);
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

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

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, X, M;
  cin >> N >> X >> M;
  llvec V(M, 0);
  ll ans = X;
  ll cnt = 1;
  while(V[X]==0){
    if(cnt==N)break;
    V[X]=cnt;
    X = (X*X)%M;
    ans += X;
    cnt++;
  }
  if(cnt==N)cout << ans;
  else{
    ll d = cnt - V[X];
    ll nloop = (N-V[X])/d;
    ll t=0;
    rep(i, d){
      X = (X*X)%M;
      t += X;      
    }
    ans = (ans - t) + nloop*t;
    N = (N-V[X])%d;
    rep(i, N){
      X = (X*X)%M;
      ans += X;      
    }
    cout << ans;
  }
  return 0;
}


Measured memory_bytes: 4052
import math
while True:
    n = int(input())
    if n == 0: break
    s = [int(e) for e in input().split()]
    average = sum(s) / n
    total = 0
    for e in s:
        total += (e - average)**2 # 偏差の２乗の合計
    print("{0: .4f}".format(math.sqrt(total/n)))



Measured memory_bytes: 5712