akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m; cin >> n >> m;
    vector<ll> x(m);
    rep(i, m) cin >> x[i];
    sort(ALL(x));

    vector<ll> diffs;
    Rep(i, 1, m) diffs.push_back(x[i] - x[i - 1]);
    sort(rALL(diffs));

    ll ans = x[m - 1] - x[0];
    rep(i, min((int)diffs.size(), n - 1)) ans -= diffs[i];
    cout << ans << endl;
}

Measured memory_bytes: 2168
n=int(input())
mod=10**9+7
if n<3:
    print(0)


else:
    a=[0]*(n)
    a[0]=0
    a[1]=0
    a[2]=1
    for i in range(3,n):
        a[i]=(a[i-3]+a[i-1])%mod
    print(a[n-1])

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  //
  ll d, t, s;
  cin >> d >> t >> s;
  bool ans = s * t >= d;
  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 3636
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B

import           Data.Array.IO
import           Data.List
import           Data.Word             (Word16)

read' :: B.ByteString -> Word16
read' bs | Just (n, _) <- B.readInt bs = fromIntegral n

_VMAX = 10000

countingSort :: [Word16] -> IO ()
countingSort as = do
    c <- newArray (0, _VMAX) 0 :: IO (IOUArray Word16 Int)

    forM_ as $ \a -> do
        t <- readArray c a
        writeArray c a (t + 1)

    bs <- getAssocs c

    putStrLn
        . unwords
        . fmap show
        . concatMap (\(i, e) -> genericReplicate e i)
        $ bs

main :: IO ()
main = do
    B.getLine
    !xs <- fmap read' . B.words <$> B.getLine
    countingSort xs



Measured memory_bytes: 22992
import sys
def input():
	return sys.stdin.readline()[:-1]

H, W, n = map(int, input().split())
r, c = map(int, input().split())
s = input()
t = input()

L, R, U, D = c, W+1-c, r, H+1-r

dp = [[0 for _ in range(4)] for _ in range(n+1)]
dp[0][0] = L
dp[0][1] = R
dp[0][2] = U
dp[0][3] = D
for i in range(1, n+1):
	if dp[i-1][0] == 1 and s[i-1] == "L":
		print("NO")
		sys.exit()
	if dp[i-1][1] == 1 and s[i-1] == "R":
		print("NO")
		sys.exit()
	if dp[i-1][2] == 1 and s[i-1] == "U":
		print("NO")
		sys.exit()
	if dp[i-1][3] == 1 and s[i-1] == "D":
		print("NO")
		sys.exit()
	for j in range(4):
		dp[i][j] = dp[i-1][j]
	if s[i-1] == "L":# and t[i-1] != "R":
		dp[i][0] -= 1
	if s[i-1] == "R":# and t[i-1] != "L":
		dp[i][1] -= 1
	if s[i-1] == "U":# and t[i-1] != "D":
		dp[i][2] -= 1
	if s[i-1] == "D":# and t[i-1] != "U":
		dp[i][3] -= 1
	if t[i-1] == "L" and dp[i][1] < W:
		dp[i][1] += 1
	if t[i-1] == "R" and dp[i][0] < W:
		dp[i][0] += 1
	if t[i-1] == "U" and dp[i][3] < H:
		dp[i][3] += 1
	if t[i-1] == "D" and dp[i][2] < H:
		dp[i][2] += 1

	#print(dp[i-1], dp[i])

#print(dp)
print("YES")

Measured memory_bytes: 32628
#include<stdio.h>
#include<string.h> 
#include<map>
using namespace std;
int main()
{
	map<int,bool> mp;
	char s[100005];
	while(scanf("%s",&s)!=EOF) {
		mp.clear();
		for(int i=0; i<strlen(s); i++) {
			mp[s[i]-'a']=true;
		}
		int flag=1;
		for(int i=0;i<26;i++) {
			if(!mp[i]){
				printf("%c\n",'a'+i);
				flag=0;
				break;
			}
		}
		if(flag) printf("None\n");
	}
	return 0;
}

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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point{
    public:
    double x,y;
    Point(double x=0,double y=0):x(x),y(y){}
    Point operator+(const Point &p){
        return Point(x+p.x,y+p.y);
    }
    Point operator-(const Point &p){
        return Point(x-p.x,y-p.y);
    }
    Point operator*(const double &a){
        return Point(a*x,a*y);
    }
    Point operator/(const double &a){
        return Point(x/a,y/a);
    }
    double abs(){
        return sqrt(norm());
    }
    double norm(){
        return x*x+y*y;
    }
    bool operator<(const Point &p){
        return x!=p.x?x<p.x:y<p.y;
    }
    bool operator==(const Point &p){
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};
typedef Point Vector;
struct Segment{
    Point p1,p2;
    Segment(){}
    Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/base.norm();
    return s.p1+base*r;   
}

Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2;
}

double getDistanceLP(Line l,Point p){
    return abs(cross(l.p2-l.p1,p-l.p1))/(l.p2-l.p1).abs();
}

double getDistanceSP(Segment s,Point p){
    if(dot(s.p2-s.p1,p-s.p1)<0){
        return (p-s.p1).abs();
    }
    if(dot(s.p1-s.p2,p-s.p2)<0){
        return (p-s.p2).abs();
    }
    return getDistanceLP(s,p);
}

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS) return 1;
    if(cross(a,b)<-EPS) return -1;
    if(dot(a,b)<-EPS) return 2;
    if(a.norm()<b.norm()) return -2;
    return 0;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
    return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&
        ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

double getDistance(Segment s1,Segment s2){
    if(intersect(s1,s2)) return 0;
    return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
        min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}

Point getCrossPoint(Segment s1,Segment s2){
    Vector base=s2.p2-s2.p1;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}

int main(){
    int q;
    int a,b,c,d,e,f;
    int x;
    cin>>a>>b>>c>>d;
    cin>>q;
    Point p0(a,b),p1(c,d);
    for(int i=0;i<q;i++){
        cin>>e>>f;
        Point p2(e,f);
        x=ccw(p0,p1,p2);
        if(x==1) cout<<"COUNTER_CLOCKWISE"<<endl;
        if(x==-1) cout<<"CLOCKWISE"<<endl;
        if(x==2) cout<<"ONLINE_BACK"<<endl;
        if(x==-2) cout<<"ONLINE_FRONT"<<endl;
        if(x==0) cout<<"ON_SEGMENT"<<endl;
    }
}


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

using namespace std;

int main() {
    int H, W;
    int n;
    cin >> H >> W >> n;
    vector<int> a(n);
    vector<int> hw(H * W);
    vector<vector<int>> ans(H, vector<int>(W, 0));

    int base = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < a[i]; ++j) {
            hw[base + j] = i + 1;
        }
        base += a[i];
    }

    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            if (h % 2) {
                ans[h][W - 1 - w] = hw[h * W + w];
            } else {
                ans[h][w] = hw[h * W + w];
            }
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << ans[i][j];
            if (j != W - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3692
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <string>
#include <queue>
#include <stack>

using namespace std;

const int maxn = 350;

char a[maxn][maxn];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",a[i]);
        //printf("%s\n",a[i]);

    }
    int sum = 0;
    for(int k=0;k<n;k++)
    {
        bool yes = true;
        for(int i=0;yes&&i<n;i++)
        {
            for(int j=0;yes&&j<n;j++)
            {
                int ii = i+k;
                int jj = j+k;
                if(i+k>=n)
                {
                    ii -= n;
                }
                if(j+k>=n)
                {
                    jj -= n;
                }
                if(a[ii][j] != a[jj][i])
                {
                    yes = false;
                }
            }
        }
        if(yes)
        {
            sum += n;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
inline int read () {
	int num = 0;
	char c = ' ';
	bool flag = true;
	for (;c > '9' || c < '0';c = getchar())
		if (c == '-')
			flag = false;
	for (;c >= '0' && c <= '9';num = (num << 1) + (num << 3) + c - 48, c = getchar());
	return flag ? num : -num;
}
const int maxn = 500;
int	x[maxn], y[maxn];
long long h[maxn];
int n;
void init () {
	n = read ();
	for (int i = 1;i <= n;i ++) {
		x[i] = read ();
		y[i] = read ();
		h[i] = read ();
	}
}
int dis (int x1,int y1,int x2,int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}
void work () {
	for (int Cx = 0;Cx <= 100;Cx ++)
		for (int Cy = 0;Cy <= 100;Cy ++) {
			long long H;
			for (int i = 1;i <= n;i ++)
				if (h[i] != 0) {
					H = h[i] + abs (x[i] - Cx) + abs (y[i] - Cy);
					break;
				}
			bool flag = true;
			for (int i = 1;i <= n;i ++)
				if (max (H - abs (x[i] - Cx) - abs(y[i] - Cy),0ll) != h[i]) {
					flag = false;
					break;
				}
			if (flag) {
				printf ("%d %d %lld\n",Cx,Cy,H);
				exit (0);
			}
		}
}
int main () {
	init ();
	work ();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long Int;

typedef pair<Int, Int> P;

Int p = 0;
Int n;
Int a[216000];

vector<P> num;
Int sz = 0;
bool nxt(Int dig, Int k){
  if(dig > sz){
    num.push_back(P(dig - sz, 0));
    sz = dig;
    return true;
  }
  while(sz - num.back().first >= dig)sz -= num.back().first, num.pop_back();
  if(sz > dig)num.back().first -= sz - dig;
  sz = dig;
  Int kcnt = 0;
  //  cout << num.size() << "++*" << num.back().second << "**" << k << endl;
  while(!num.empty() && num.back().second == k-1){
    kcnt += num.back().first;
    num.pop_back();
  }
  
  //  cout << num.size() << "++*" << num.back().second << "*****" << k << endl;
  if(num.empty())return false;
  if(num.back().first == 1)num.back().second++;
  else{
    Int val = num.back().second + 1;
    num.back().first--;
    num.push_back(P(1,val));
  }
  if(kcnt)num.push_back(P(kcnt, 0));
  return true;
}

bool check(Int x){
  //  cout << "aaa" << x << endl;
  num.clear();
  sz = 0;
  for(Int i = 0;i < n;i++){
    if(!nxt(a[i], x))return false;
    /*for(Int j= 0;j < num.size();j++){
      cout << "(" << num[j].first << " " << num[j].second << ")" << endl;
      }*/
    sz = a[i];
  }
  
  return true;
}

int main(){
  cin >> n;
  for(Int i = 0;i < n;i++){
    cin >> a[i];
  }
  
  Int bottom = 1, top = n;
  while(top - bottom > 1){
    Int mid = (top + bottom) /2;
    if(check(mid))top = mid;
    else bottom = mid;
    //    cout << bottom << "=====" <<top << endl;
  }
  if(check(1))cout << 1 << endl;
  else cout << top << endl;
  return 0;
}

Measured memory_bytes: 7536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int k;
  cin >> k;
  vector<ll> a(k);
  rep(i,k) cin >> a[i];
  if (a[k-1] != 2) {
    cout << -1 << endl;
    return 0;
  }
  if (k == 1) {
    cout << 2 << " " << 3 << endl;
    return 0;
  }
  vector<ll> b(k+1), c(k+1); //min, max
  b[k] = 2; c[k] = 2;
  for (int i = k-1; i > 0; --i) {
    b[i] = a[i-1] * ((b[i+1] + a[i-1] - 1)/a[i-1]);
    c[i] = a[i-1] * ((c[i+1] + a[i] - 1)/a[i-1]);
  }
  b[0] = b[1];
  c[0] = c[1] + a[0] - 1;
  if (b[0] > c[0]) cout << -1 << endl;
  else cout << b[0] << " " << c[0] << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n;

	cin >> n;

	vector<ll> v(n, 0);

	REP(i, n) {
		cin >> v[i];
	}

	sort(v.begin(), v.end(), greater<ll>());

	ll sum = 0;

	FOR(i, 1, n) {
		sum += v[i];
	}

	if (v[0] < sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <string>

#include <iostream>
#include <vector>

void year_month_day(std::string s,int &y, int &m, int&d)
{
	sscanf(s.c_str(), "%d\/%d\/%d",&y,&m,&d);
}

int main()
{
	std::string s;
	std::cin >> s;
	int y, m, d;
	year_month_day(s, y, m, d);
	//std::cout << y << m << d;
	if (y <= 2019 && m <= 4 && d <= 30) {
		std::cout << "Heisei";
		return 0;
	}
	std::cout << "TBD";
	return 0;

}

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

/*** Template Begins ***/

typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;

#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};

/*** Template Ends ***/
std::vector<string> p;
void permute(string str, string out) 
{ 
    // When size of str becomes 0, out has a 
    // permutation (length of out is n) 
    if (str.size() == 0) 
    { 
        p.push_back(out);
        return; 
    } 
  
    // One be one move all characters at 
    // the beginning of out (or result) 
    for (int i = 0; i < str.size(); i++) 
    { 
        // Remove first character from str and 
        // add it to out 
        permute(str.substr(1), out + str[0]); 
  
        // Rotate string in a way second character 
        // moves to the beginning. 
        rotate(str.begin(), str.begin() + 1, str.end()); 
    } 
} 

   void solve()
{
   ll n,we;
   cin>>n>>we;
   std::vector<ll> v(n+1),w(n+1);
   ll dp[n+1][we+1];
   ll i,j;
   for(i=1;i<n+1;i++)
      cin>>w[i]>>v[i];
   for(i=0;i<n+1;i++)
    {
      dp[i][0]=0;
    }
    for(i=0;i<we+1;i++)
    {
      dp[0][i]=0;
    }
   for(i=1;i<=n;i++)
   {
    for(j=1;j<=we;j++)
    {
      if(j-w[i]>=0)
      {
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
      }
      else
        dp[i][j]=dp[i-1][j];
    }
   }  
   cout<<dp[n][we];
  }
  
int main(){
  
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int t;
  //cin >> t;
  t = 1;
  while(t--)
    solve();

  return 0;
}

Measured memory_bytes: 79232
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
using namespace std;
typedef long long LL;

char a[110], b[110];

int main()
{
	cin >> a >> b;
	if(strlen(a) > strlen(b))	{puts("GREATER"); return 0;}
	else if(strlen(a) < strlen(b))	{puts("LESS"); return 0;}
	else {
		for(int i = 0; i < strlen(a); i++){
			if(a[i] == b[i]) continue;
			else if(a[i] > b[i]){puts("GREATER"); return 0;}
			else {puts("LESS"); return 0;}
		}
	}
	puts("EQUAL");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <string>
using namespace std;
int judge(char,char);
int main(){
    int N,sum = 0,min = 0,place = 0;
    string S;
    cin >> N >> S;
    for(int i = 0;i < N-1;i ++){
        sum += judge(S.at(i),S.at(i+1));
        if(sum < min){
            place = i+1;
          	min =sum;
        }
    }
    int ans = 0;
    for(int i = 0;i < place;i ++){
        if(S.at(i) == 'W') ans ++;
    }
    for(int i = place+1;i < N;i ++){
        if(S.at(i) == 'E') ans ++;
    }
    cout << ans << endl;
}

int judge(char c1,char c2){
        if(c1 == 'E' && c2 == 'E'){
            return -1;
        }else if(c1 == 'W' && c2 == 'W'){
            return 1;
        }else{
            return 0;
        }
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
int main() {
  int d;
  //int n=0;//
  cin >>d;
  int c[26]; int s[d][26];
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    //n+=c[i];//
  }
  for (int i = 0; i < d; i++) {
    for (int ii = 0; ii < 26; ii++) {
      cin >> s[i][ii];
    }
  }
  long long int la[d];
  int lad[26];
  for (int i = 0; i < 26; i++) {
    lad[i]=-1;
  }
  int mm,md;
  //long long int m=0;//満足度確認用
  for (int i = 0; i < d; i++) {
    md=0;
    //la[i]=(n-c[0])*(-i-1)+s[i][0];//
    la[i]=s[i][0];
    for(int ii = 1; ii < 26; ii++) {
      la[i]-=(i-lad[ii])*c[ii];
    }
    for (int ii = 1; ii < 26; ii++) {
      //mm=(n-c[ii])*(-i-1)+s[i][ii];//
      mm=s[i][ii];
      for(int iii = 0; iii < 26; iii++) {
        if(ii!=iii) mm-=(i-lad[iii])*c[iii];
      }
      if((la[i]+c[ii]<mm+c[md])||(la[i]==mm&&c[md]<c[ii])){
        la[i]=mm; md=ii;
      }
    }
    lad[md]=i;
    cout<<md+1<<endl;
    //m+=la[i];//満足度確認用
    //cout<<m<<endl;//満足度確認用
  }
  //cout<<m<<endl;//満足度確認用
  //cout<<n<<endl;//
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll a, b;
    cin >>a >>b;
    ll r = 0;
    ll n = a;
    
    while (true) {
        r++;
        n*=2;
        if (n > b) break;
    }
    mes (r);
    
    
   
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c[1000][1000]={};
  int q=0,w=0;
  cin>>a>>b;
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin>>c[i][j];
      c[i][b]=c[i][b]+c[i][j];
      c[a][j]=c[a][j]+c[i][j];
      c[a][b]=c[a][b]+c[i][j];
    }
  }
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      cout<<c[i][j];
      if(j!=b) cout<<" ";
    }
    cout<<"\n";
  }
}




Measured memory_bytes: 6984
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define pii pair<int,int>
using namespace std;

ll gcd(ll a, ll b) {
	if(a < b) swap(a, b);

	while(b > 0) {
		ll temp = a % b;
		a = b;
		b = temp;

		if(a < b) swap(a, b);
	}

	return a;
}

int main() {
	ll k;
	cin>>k;
	ll result = 0LL;
	for(int i=1;i<=k;i++) {
		for(int j=1;j<=k;j++) {
			for(int d=1;d<=k;d++) {
				//cout<<i<<", "<<j<<", "<<d<<" - "<<gcd(gcd(i, j), d)<<"\n";
				result += 1LL * gcd(gcd(i, j), d);
			}
		}
	}
	cout<<result;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main() {
int A, B, M;
cin >> A >> B >> M;
vector<int> a(A);
vector<int> b(B);
for (int i = 0; i < A; i++)cin >> a[i];
for (int i = 0; i < B; i++)cin >> b[i];
int minA = *min_element(a.begin(), a.end());
int minB = *min_element(b.begin(), b.end());
 int ans = minA+minB;
 for (int i = 0; i < M; i++) {
 int x, y, c;
 cin >> x >> y >> c; x--; y--;
 ans = min(ans, a[x] + b[y] - c);
 }
 cout << ans << endl;
 return 0;
 }


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
	#define author          "Sihare0riginals"
	#define ss       		string 
	#define lli      		long long int
	#define ld       		long double
	#define f        		first
	#define s        		second
	#define all(v)   		v.begin(),v.end()
	#define I(a,i)			memset(a,i,sizeof(a));
	#define pb       		push_back
	#define mp       		make_pair
	#define L(i,start,end)  for(lli i=start;i<=end;i++)
	#define R(i,start,end)  for(lli i=start;i>=end;i--)
	#define ip(n) 			cin>>n;lli ip[n+1];L(i,1,n)cin>>ip[i];
const lli LINF = 1e18,mod=1e9+7;
void Bl0ck_M0mb0();


signed main()
{
	Bl0ck_M0mb0();
	lli t=1;
	//cin>>t;
	while(t--){
		char ch;
		cin>>ch;
		if(ch>='a'&&ch<='z')
			cout<<"a"<<endl;
		else
			cout<<"A"<<endl;
	}
	return 0;
}


















void Bl0ck_M0mb0(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("ip.txt","r",stdin);
	freopen("op.txt","w",stdout);
	#endif
}
/*
#define dbg1D(i,start,end,arr) for(lli i=start;i<=end;i++) cout<<i<<"th : "<<arr[i]<<endl;
#define dbg2D(i,j,s1,e1,s2,e2,arr) for(lli i=s1;i<=e1;i++){cout<<i<<"th :";for(lli j=s2;j<=e2;j++)cout<<arr[i][j]<<" ";cout<<endl;}
#define M map<lli,lli> \n #define sz(s) s.size()-1
#define P pair<lli,lli> 
#define V vector<lli>
lli dx[4]={-1, 0, 0, +1};
lli dy[4]={0, -1, +1, 0};
lli power(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m;
 	lli t=power(a,b/2,m); t=(t*t)%m; if(b&1) t=(t*a)%m; return t;}
lli modInverse(lli a, lli m) { return power(a, m-2, m); } */

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <time.h>
#include <algorithm>
#include <random>

using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cout.precision(20);

    int n, m;
    cin >> n >> m;
    if (n > m) swap(n, m);

    if (n == 1) {
        if (m == 1) {
            cout << "1\n";
            return 0;
        }
        else {
            cout << m - 2 << '\n';
            return 0;
        }
    }

    cout << (n - 2) * (m - 2) << '\n';

    return 0;
}

Measured memory_bytes: 256
def main():
    from numpy import array,searchsorted,sum,hstack
    n,*t=map(int,open(0).read().split())
    a,b=array(t[:n],'i4'),array(t[n:],'i4')
    c=0
    for k in range(28,-1,-1):
        l,h=pow(2,k),pow(2,k+1)
        a%=h
        b%=h
        b.sort()
        y=hstack((b-h,b))
        i=searchsorted(y,l-a)
        j=searchsorted(y,h-a)
        m=sum(j-i)
        c+=m%2*l
    print(c)
if __name__=='__main__':
    main()

Measured memory_bytes: 56188
loop = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)

manhattan, euclid, p3, chebyshev = 0.0, 0.0, 0.0, (x[0] - y[0]).abs
loop.times{|i|
    manhattan += (x[i] - y[i]).abs
}

loop.times{|i|
    euclid += (x[i] - y[i]).abs ** 2
}

loop.times{|i|
    p3 += (x[i] - y[i]).abs ** 3
}

loop.times{|i|
    chebyshev = [chebyshev, (x[i] - y[i]).abs].max
}

puts manhattan
puts euclid ** (1.0/2.0)
puts p3 ** (1.0/3.0)
puts chebyshev



Measured memory_bytes: 6944
#include<stdio.h>
#include<algorithm>

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

const int s=1001*501;
int dp[s];
int n,m,ans,p[1001],cnt;
int *po;
using namespace std;


int main(){
	for(;;){
		scanf("%d%d",&n,&m);
		if(n==0&&m==0)break;
		p[0]=0;
		rep(i,n)scanf("%d",p+i+1);
		cnt=0;
		rep(i,n+1){
			for(int j=0;j<=i;j++){
				dp[cnt++]=p[i]+p[j];
			}
		}
		ans=0;
		sort(dp,dp+cnt);
		rep(i,cnt){
			po = upper_bound(dp,dp+cnt,m-dp[i]);
			if(po!=dp)ans=max(ans,dp[i]+*(po-1));
		}
	//	rep(i,cnt)printf("%3d",dp[i]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3004
from sys import stdin
import re
flug = 0
l = stdin.readline()
for i in range(7):
    pattern = list("keyence$")
    pattern.insert(i, "[a-z]*")
    #print("".join(pattern))
    r = re.compile("".join(pattern))
    if (r.match(l) != None) :
        if flug == 0:
            print("YES")
        flug = 1

if(flug == 0):
    print("NO")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int s[200005],t[200005];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&s[i]);
    int m=n;
    bool flag=false;
    for(int i=1; i<=n; i++) {
        if(m<=0) {
            flag=true;
            if(m==0)
                m=1;
            else
                m=2;
        }
        if(!flag) {
            t[i]=m;
            m-=2;
        } else {
            t[i]=m;
            m+=2;
        }
    }
    for(int i=1; i<n; i++)
        printf("%d ",s[t[i]]);
    printf("%d\n",s[t[n]]);
    return 0;
}



Measured memory_bytes: 3712
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;
const int MAX_N = 200000 +10;

struct BIT{
    int N;
    LL a[MAX_N];

    void clear(int n){
        N = n;
        for (int i=0;i<=N;i++) a[i] = 0;
    }
    int lowbit(int x){
        return x & (-x);
    }
    void update(int x){
        for (;x <= N;x += lowbit(x))
            a[x]++;
    }
    LL sum(int x)
    {
        LL ret = 0LL;
        for (; x; x -= lowbit(x))
            ret += a[x];
        return ret;
    }
} tree;

LL b[MAX_N],s[MAX_N];
map<LL,int> mp;

int main()
{
    int n, m, x;
    scanf("%d%d",&n,&m);

    mp.clear();
    tree.clear(n);
    LL ans = 0LL;

    for (int i=1;i<=n;i++){
        scanf("%d",&x);
        s[i] = s[i - 1] + x - m;
        if (s[i] < 0) ans++;
        b[i] = s[i];
    }
    sort(b+1,b+n+1);

    for (int i=1;i<=n;i++)
       if (mp[b[i]] == 0) mp[b[i]] = i;

    for (int i=n;i>=1;i--){
        x = mp[s[i]];
        ans += tree.sum(x);
        tree.update(x+1);
    }
    printf("%lld\n",1LL * n * (n + 1) / 2 - ans);
}


Measured memory_bytes: 17408
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int A[1010],done[1010000];
int n,m;

int main() {
    scanf("%d",&n);
    for (int i = 1; i <= n; i++) {
	scanf("%d",&A[i]);
    }
    for (int i = 1; i <= n; i++) {
	int k = 0;
	for (int j = i; j <= min(n, i + 3); j++) {
	    k = k * 10 + A[j];
	    done[k] = 1;
	}
    }
    for (int i = 0; i <= 10000; i++) {
	if (!done[i]) {
	    printf("%d\n",i);
	    return 0;
	}
    }
    return 0;
}

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

namespace _0282
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nrl = RArInt();
            int[] Scores = new int[nrl[0]];
            int[] airingSeconds = new int[nrl[0]];

            Tuple<int, int> top = new Tuple<int, int>(0, 0);
            int lastlogSeconds = 0;

            for (int i = 0; i < nrl[1]; i++)
            {
                int[] vs = RArInt();
                airingSeconds[top.Item1] += vs[1] - lastlogSeconds;
                lastlogSeconds = vs[1];

                Scores[vs[0] - 1] += vs[2];
                if (Scores[vs[0] - 1] > top.Item2 || Scores[vs[0] - 1] == top.Item2 && vs[0] - 1 < top.Item1)
                {
                    top = new Tuple<int, int>(vs[0] - 1, Scores[vs[0] - 1]);
                }
                else if (vs[0] - 1 == top.Item1 && vs[2] < 0)
                {
                    top = Scores.Select((x, idx) => new Tuple<int, int>(idx, x)).OrderByDescending(y => y.Item2).ThenBy(y => y.Item1).FirstOrDefault();
                }
            }
            airingSeconds[top.Item1] += nrl[2] - lastlogSeconds;
            Console.WriteLine(airingSeconds.Select((x, i) => new Tuple<int, int>(i, x)).OrderByDescending(y => y.Item2).ThenBy(y => y.Item1).FirstOrDefault().Item1 + 1);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 43656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (count(all(s), 'A') != 0 && count(all(s), 'A') != 3) puts("Yes");
	else puts("No");
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
#define cout_set(n) cout << setprecision(10) << (n) << endl; 
const double PI=3.14159265358979323846;
using namespace std;
const int mod = 1000000007; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

int correct(string s,string t){
    int c=1;
    rep(i,t.length()){
        if(s[i] != t[i]){
            if(s[i] != '?'){
                c = -1;
                break;
            }
        }
    }
    return c;
}

signed main(){
    string s,t; cin >> s >> t;
    int start=-1;
    for(int i=0;i<s.length()-t.length()+1;i++){
        if(correct( s.substr(i,t.length()), t) == 1){
            start = i;
        }
    }
    //check
    if(start == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    string ans = s;
    ans.replace(start,t.length(),t);
    rep(i,ans.length()) 
        if(ans[i] == '?') ans.replace(i,1,"a");
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<int> rem(N + 1);
    ll mo = 0;
    ll coef = 1;
    for(int i = N - 1; i >= 0; i--) {
        mo += (S[i] - '0') * coef;
        mo %= 2019;
        rem[i] = mo;
        coef *= 10;
        coef %= 2019;
    }
    map<int, ll> mp;
    rep(i, N + 1) { mp[rem[i]]++; }
    ll res = 0;
    for(auto x : mp) {
        res += (x.second - 1) * (x.second) / 2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,n) for(ll i=0;i<n;i++)
#define fa(i,a,b) for(ll i=a;i<=b;i++)
#define fr(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ms(array,value) memset(array,value,sizeof(a))
#define test(t) ll t; cin>>t; while(t--)
#define en cout<<endl;


int main()
{
sync
ll k,n;
cin>>k>>n;
ll a[n];
f(i,n)cin>>a[i];
bool flag=false;
f(i,n)
{
    k-=a[i];
    if(k<=0)
    {
        flag=true;
        break;
    }
}if(flag)cout<<"Yes";else cout<<"No";
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ANTHRO(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define ANTHRO(x...)
#endif


#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define EPS 1e-9
/*
	XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    No, nothing good starts in a getaway car
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double pi=3.1416;
    long double r; cin>>r;
    cout<<setprecision(5)<<(long double)(2*pi*r)<<endl;
    return 0;//I am assuming that my sol is corrects
}


Measured memory_bytes: 3808
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

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

    int k, a, b;
    cin >> k >> a >> b;
    if (a / k != b / k)
    {
        cout << "OK"
             << "\n";
        return 0;
    }
    if (a % k == 0 || b % k == 0)
    {
        cout << "OK"
             << "\n";
        return 0;
    }
    cout << "NG"
         << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
using namespace std;
#define INF 100000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main(){
    int a,b,x;
    cin>>a>>b>>x;
    if((double)a*a*b/2<=x){
        double ae=(double)(a*a*b-x)/(a*a)*2;
        double ans=rad_to_deg(atan(a/ae));
        printf("%.9lf\n",90-ans);
    }else{
        double ans=rad_to_deg(atan((double)(2*x)/(a*b*b)));
        printf("%.9lf\n",90-ans);
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>
#include <map>
#include <math.h>
#include <vector>

#define INF 100000000

using namespace std;
char a[114], b[114];

int stoi(char o){
  return (o - '0');
}

int main(){
  scanf("%s%s", a, b);
  int an = strlen(a);
  int bn = strlen(b);
  if(an > bn){
    printf("GREATER\n");
    return 0;
  }else if(an < bn){
    printf("LESS\n");
    return 0;
  }else{
    for(int i = 0; i < an; i++){
      if(stoi(a[i]) < stoi(b[i])){
        printf("LESS\n");
        return 0;
      }else if( stoi(a[i]) > stoi(b[i])){
        printf("GREATER\n");
        return 0;
      }
    }
  }
  printf("EQUAL\n");
}



Measured memory_bytes: 128
import java.io.*;

class Main
{
    public static void main (String[ ] args) throws Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true)
        {
            String str[] = br.readLine().split(" ");
            int m = Integer.parseInt(str[0]);
            int f = Integer.parseInt(str[1]);
            int r = Integer.parseInt(str[2]);
            
            if(-1 == m && -1 == f && -1 == r)
            {
                break;
            }
            
            if(-1 == m || -1 == f)
            {
                System.out.println("F");
            }
            else if(80 <= m + f)
            {
                System.out.println("A");
            }
            else if(65 <= m + f)
            {
                System.out.println("B");
            }
            else if(50 <= m + f)
            {
                System.out.println("C");
            }
            else if(30 <= m + f)
            {
                if(50 <= r)
                {
                    System.out.println("C");
                }
                else
                {
                    System.out.println("D");
                }
            }
            else
            {
                System.out.println("F");
            }
        }
    }
}

Measured memory_bytes: 24112
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = int_fast64_t;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

constexpr int MOD = 1'000'000'007;

long long power(long long x, long long n, long long mod = 1000000007) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

LL kai[100000+2] = {};

LL cnk(const LL &n, const LL &k) {
    //cerr << n << " " << k << endl;
    if (n < k) return 0;
    /*
    LL ans = 1;
    REP(i,1,n+1) {
        ans = (ans * i) % MOD;
    }
    LL div = 1;
    REP(i,1,k+1)  div = (div * i) % MOD;
    REP(i,1,n-k+1)  div = (div * i) % MOD;
    */
    LL ans = kai[n];
    //dump(ans);
    LL div = (kai[k] * kai[n-k]) % MOD;
    //dump(div);
    return (ans * power(div, MOD-2)) % MOD;
}

void solve() {
    kai[0] = 1;
    kai[1] = 1;
    REP(i,2,100001) kai[i] = (kai[i-1] * (LL)i) % MOD;
    int l, r;
    int n;
    cin >> n;
    VI a(n+1),c(n+1);
    REP(i,0,n+1) {
        cin >> a[i];
        if (c[a[i]] != 0) r = i;
        ++c[a[i]];
    }
    REP(i,0,n+1) if (a[i] == a[r]) {
        l = i;
        break;
        
    }
    //dump(l);
    //dump(r);
    REP(k,1,n+2) {
        if (k == 1) {
            cout << n << endl;
            continue;
        }
        if (k == n+1) {
            cout << 1 << endl;
            continue;
        }
        if (k == 2) {
            //cout << LL(n) * (n - 1) / 2 + r - l - 1 + 1 << endl;
            cout << (cnk(n,2) + r - l - 1 + 1) % MOD << endl;
            continue;
        }
        LL sum = cnk(n,k);
        //cout << "sum: " << sum << endl;
        sum = (sum + cnk(n-1,k-2)) % MOD;
        //cout << "sum: " << sum << endl;
        //dump(sum);
        sum = (sum + cnk(n-1,k-1)) % MOD;
        sum = (sum - cnk((n-1)-(r-l-1),k-1) + MOD) % MOD;
        //sum = (sum + cnk(n-1,k-1) - cnk(r-l-1,k-1) + MOD) % MOD;
        cout << sum << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>

using namespace std;
int d[60];
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int t=c;
	int now=0;
	int ans=0;
	while(1){
		d[now%60]++;
		if(d[now%60]>1){
			ans=-1;
			break;
		}
		if(now>t)t+=60;
		if(now+a>=t && t>=now){
			ans=t;
			break;
		}
		now+=a+b;
	}
	cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice = 0;
  int Bob = 0;
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Alice += a.at(i);
    }
    else {
      Bob += a.at(i);
    }
  }
  
  cout << Alice - Bob << endl;
}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    ll k;
    cin >> k;
    while(k > 1 && k % 2 == 0) k /= 2, ans++;
  }
  cout << ans << endl;
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#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 YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;


    
int main(){
    int N;
    cin >> N;
    vi A(N);
    REP(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    A.push_back(0);
    
    int count = 0;
    int len = 1;
    REPS(i,N){
        if(A[i]!=A[i-1]){
            //cout << i << endl;
            //HOGE;
            if(len%2==1){
                count++;
                //HOGE;
            }
            len = 0;
        }
        len++;
    }
    cout << count << endl;
}


Measured memory_bytes: 1152
N = input()
N = int(N)
An = list(map(int, input().split()))

cnt = 0
step = []
step_sum = 0

for i in range(0, N):
    if i == 0:
        step.append(0)
        continue
    diff = (An[i - 1] + step[i - 1]) - An[i]
    if diff <= 0:
        step.append(0)
    else:
        step.append(diff)

for num in step:
    step_sum += num

print(step_sum)


Measured memory_bytes: 32216
from collections import defaultdict

N=int(input())
A=[int(x) for x in input().split()]
Q=int(input())
D=[0 for i in range(100001)]
ans=0
for a in A:
    D[a]+=1
for i in range(100001):
    ans+=i*D[i]

for i in range(Q):
    B,C=[int(x) for x in input().split()]
    tmp1=D[B]*B
    D[C]+=D[B]
    tmp2=D[B]*C
    D[B]=0
    ans=ans-tmp1+tmp2
    print(ans)

Measured memory_bytes: 83084