akhauriyash/Code-Regression huggingface dataset:
/*=======================
Author    : Shounak Dey
Filename  : c.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	ll n,x;
	cin >> n >> x;
	ll ret=0;
	vector<ll> arr(n);
	REP(i,n){
		cin >> arr[i];
		if(arr[i]>x){
			ret += arr[i]-x;
			arr[i] = x;
		}
	}
	FOR(i,1,n){
		if((arr[i] + arr[i-1])>x){
			ret += (arr[i]+arr[i-1])-x;
			arr[i] = x-arr[i-1];
		}
	}
	cout << ret << endl;
	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int d,g;cin >> d >> g;
    vector<int> a(d);
    vector<int> b(d);
    REP(i,d)cin >> a[i] >> b[i];
    
    int ans = INF;
    for(int bit=0;bit<(1<<d);bit++){
        int count=0,score=0;
        for(int i=0;i<d;i++){
            if(bit&(1<<i)){
                count+=a[i];
                score+=(100*(i+1)*a[i]+b[i]);
            }
        }
        if(score>=g)ans = min(ans,count);
        else{
            for(int i=d-1;i>=0;i--){
                if(bit&(1<<i))continue;
                for(int j=0;j<a[i];j++){
                    if(score>=g)break;
                    count++;
                    score+=100*(i+1);
                }
            }
            ans = min(ans,count);
        }
    }
    COUT(ans);
    return 0;
}

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

int main(){
    int N;  cin >> N;
    vector<int> A(N+2);
    A[0] = 0;
    for(int i=1;i<=N;i++)    cin >> A[i];
    A[N+1] = 0;

    vector<int> suml(N+2);
    suml[0] = 0;
    for(int i=1;i<=N+1;i++){
        suml[i] = suml[i-1] + abs( A[i] - A[i-1] );
    }

    vector<int> sumr(N+2);
    sumr[N+1] = 0;
    for(int i=N;i>=0;i--){
        sumr[i] = sumr[i+1] + abs( A[i] - A[i+1] );
    }

    for(int i=1;i<=N;i++){
        int lcost = suml[i-1];
        int res = abs(A[i+1] - A[i-1]);
        int rcost = sumr[i+1];
        int ans = lcost + rcost + res;
        cout << ans << endl;
    }

}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll A[100010];
ll B[100010];
int main()
{
  ll N, res = 0;
  cin >> N;
  for (ll i = 0; i <= N; i ++) cin >> A[i];
  for (ll i = 0; i < N; i ++) cin >> B[i];
  for (ll i = 0; i < N; i ++)
  {
  	if (B[i] < A[i]) res += B[i], A[i] -= B[i];
  	else
  	{
  		if (A[i] + A[i + 1] <= B[i])
  		{
  			res += A[i] + A[i + 1];
  			A[i] = 0, A[i + 1] = 0;
			}
			else
			{
				A[i + 1] -= B[i] - A[i], A[i] = 0;
				res += B[i];
			}
		}
	}
	cout << res << endl;
}


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


int main() {
 
  int a,b,c,d; cin >> a>> b >> c >> d;
  if ( abs(c - a) <= d ) cout << "Yes" ;
  else if ( abs(b-a) <=d && abs(c-b) <=d ) cout << "Yes";
  else cout << "No" ;
  
  
}

Measured memory_bytes: 256
open Batteries

module Int64map = Map.Make(Int64)

let () =
  let a = Scanf.scanf "%d\n" (fun a -> a) in

  let arr = Array.make a 0L in
  for i = 0 to a-1-1 do
    let c = Scanf.scanf "%Ld " (fun c -> c) in
    Array.set arr i c
  done;
  let c = Scanf.scanf "%Ld\n" (fun c -> c) in
  Array.set arr (a-1) c;

  let arr2 = Array.make a 0L in
  for i=0 to a-1 do
    arr2.(i) <- (Int64.add arr.(i) (if i<>0 then arr2.(i-1) else 0L));
  done;

  let arr2 = Array.append arr2 [|0L|] in

  let nc2 n =
    if n < 2L then 0L else Int64.div (Int64.mul n (Int64.sub n 1L)) 2L
  in

  let m = ref Int64map.empty in

  Array.iter (fun x ->
      if Int64map.mem x !m then (
        m := Int64map.add x (Int64.add (Int64map.find x !m) 1L) !m;
      ) else (
        m := Int64map.add x 1L !m;
      );
    ) arr2;

  let mm = Int64map.map (nc2) !m in
  let cnt = Int64map.fold (fun k v1 v2 -> Int64.add v1 v2) mm 0L in

  print_endline (Int64.to_string cnt)


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

using namespace std ;

#define N  10000010
#define ll long long int

//bool prime[N] ;
vector<bool>prime;

int main()
{
int len;
string s,f,l;
cin >>s;
len=s.size();
f=s[0];
l=s[len-1];
//cout <<len<<" "<<f<<" "<<l<<" ";
cout <<f<<len-2<<l<<endl;


}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
price = A * X + B * Y
x = X
y = Y

for i in range(max(X, Y)):
    if x > 0 and y > 0:
        d = A + B - C * 2
    elif x <= 0:
        d = B - C * 2
    elif y <= 0:
        d = A - C * 2

    price = min(price, price - d)
    x -= 1
    y -= 1

print(price)

Measured memory_bytes: 3064
#line 1 "power.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B"
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/math/modint.hpp"
#include <cstdint>
#include <iostream>
#ifndef MOD_INT
#define MOD_INT

template <std::uint_fast64_t MOD> class ModInt {
  using u64 = std::uint_fast64_t;

public:
  ModInt(const u64 val = 0) { value = val % MOD; }

  ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }

  ModInt &operator+=(const ModInt rhs) {
    value += rhs.value;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator-=(const ModInt rhs) {
    if (value < rhs.value) {
      value += MOD;
    }
    value -= rhs.value;
    return *this;
  }

  ModInt &operator*=(const ModInt rhs) {
    value = value * rhs.value % MOD;
    return *this;
  }

  ModInt &operator/=(ModInt rhs) {
    *this *= rhs.inv();
    return *this;
  }

  ModInt &operator++(int n) {
    value++;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator--(int n) {
    if (value == 0) {
      value += MOD;
    }
    value--;
    return *this;
  }

  ModInt inv() { return ModInt::pow(*this, MOD - 2); }

  static ModInt pow(ModInt base, long long int n) {
    ModInt res = ModInt(1);
    while (n) {
      if (n & 1) {
        res *= base;
      }
      base *= base;
      n /= 2;
    }
    return res;
  }

  static ModInt comb(ModInt n, ModInt r) { return comb(n.value, r.value); }

  static ModInt comb(int n, int r) {
    if (n < r)
      return ModInt(0);
    ModInt res = ModInt(1);
    for (int i = 0; i < r; i++) {
      res *= ModInt(n - i);
    }

    ModInt inv = ModInt(1);
    for (int i = 0; i < r; i++) {
      inv *= ModInt(r - i);
    }
    return res / inv;
  }

  u64 getValue() const { return value; }

private:
  u64 value;

  friend std::ostream &operator<<(std::ostream &out, const ModInt<MOD> &m) {
    out << m.value;
    return out;
  }

  friend std::istream &operator>>(std::istream &in, ModInt &m) {
    uint_fast64_t i;
    in >> i;
    m = ModInt(i);
    return in;
  }
};

#endif
#line 4 "power.cpp"

using mint = ModInt<1000000007>;

int main() {
  mint m;
  int n;
  std::cin >> m >> n;
  std::cout << mint::pow(m, n) << std::endl;
}



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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();
  if (N & 1) N *= 2;

  cout << N << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    int x, y; cin >> x >> y;
    bool possible = false;
    for (int k = 0; k <= x; k++) {
        int t = x - k;
        if (2 * t + 4 * k == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

int main() {
  ll N, M;
  cin >> N >> M;
  ll ts=1;
  if (abs(N-M)==0) {
    for (ll i=1; i<=N; i++) {
      ts *= (i * i) % 1000000007;
      ts %= 1000000007;
    }
    cout << (ts*2) % 1000000007 << endl;
  } else if (abs(N-M)==1) {
    ll ma = max(N, M);
    ll mi = min(N, M);
    for (ll i=1; i<=ma; i++) {
      ts *= i % 1000000007;
      ts %= 1000000007;
    }
    for (ll i=1; i<=mi; i++) {
      ts *= i % 1000000007;
      ts %= 1000000007;
    }
    cout << ts << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q  
li=[0]*100001
for a in A:
  li[a]+=1
su=sum(A)
for q in range(Q):
  B,C=list(map(int, input().split())) 
  su += li[B] * (C-B)
  li[C]+=li[B]
  li[B]=0
  print(su)  

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


def number2alphabet(num):
    if num <= 26:
        return chr(96 + num)
    elif num % 26 == 0:
        return number2alphabet(num//26 - 1) + chr(122)
    else:
        return number2alphabet(num//26) + chr(96+num % 26)


print(number2alphabet(N))


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

int main(){
    int H, W, N;
    cin>>H>>W>>N;
    int sy, sx;
    cin>>sy>>sx;
    string F, S;
    cin>>F>>S;
    int fpc, fnc, spc, snc;
    fpc=fnc=spc=snc=0;
    bool flag = false;
    for(int i=0;i<N;++i){
        if(F[i]=='L'){
            ++fnc;
            if(sx-(fnc-spc)<=0){
                flag = true;
                break;
            }
        }else if(F[i]=='R'){
            ++fpc;
            if(sx+fpc-snc>W){
                flag = true;
                break;
            }
        }
        if(S[i]=='L'){
            ++snc;
            if(sx+fpc-snc==0)--snc;
        }else if(S[i]=='R'){
            ++spc;
            if(sx-fnc+spc==W+1)--spc;
        }
    }
    fpc=fnc=spc=snc=0;
    for(int i=0;i<N;++i){
        if(F[i]=='U'){
            ++fnc;
            if(sy-(fnc-spc)<=0){
                flag = true;
                break;
            }
        }else if(F[i]=='D'){
            ++fpc;
            if(sy+fpc-snc>H){
                flag = true;
                break;
            }
        }
        if(S[i]=='U'){
            ++snc;
            if(sy+fpc-snc==0)--snc;
        }else if(S[i]=='D'){
            ++spc;
            if(sy-fnc+spc==H+1)--spc;
        }
    }
    cout << (!flag ? "YES" : "NO") << endl;
    return 0;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool ans=1;
  if(a==b && b==c && c==a) ans=0;
  if(a!=b && b!=c && c!=a) ans=0;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <cstdio>
using namespace std;
typedef complex<double> P;

#define double long double

struct Par {
  double a,b,c;
  double func(double x) {
    return a*x*x + b*x + c;
  }
  double integral(double x) {
    double X = 2*a*x+b;

    double Y = log(X + sqrt(1+X*X));
    // double theta = atan(X);
    // Y = log(abs(1+sin(theta))/abs(1-sin(theta)))/2;
    
    double res = (X*sqrt(X*X+1) + Y) * 0.5;
    res /= 2*a;
//    cout << res << endl;
    return res;
  }
  double integral(double x1, double x2) {
    // double res = 0;
    // for (double x = x1; x<x2; x += 0.0001) {
    //   P p(x,func(x));
    //   P q(x+0.0001, func(x+0.0001));
    //   res += abs(p-q);
    // }
    // return res;
    return integral(x2) - integral(x1);
  }
};
Par par[100];

const double EPS = 1e-10;

vector<double> crosspoint(const Par &p, const Par &q) {
  double A = p.a-q.a;
  double B = p.b-q.b;
  double C = p.c-q.c;
  vector<double> res;
  if (abs(A) < EPS) {
    if (abs(B) < EPS) {
      return res;
    }
    res.push_back(-C/B);
    return res;
  }
  
  double D = B*B - 4*A*C;
  if (D < 0) {
    return res;
  }
  res.push_back((-B+sqrt(D))/(2*A));
  if (D > EPS) {
    res.push_back((-B-sqrt(D))/(2*A));
  }
  return res;
}


int main() {
  double w,h;
  int n;
  while(cin>>w>>h>>n) {
    for (int i = 0;i<n; ++i) {
      double a,p,q;
      cin >> a >> p >> q;
      double b = -2*a*p;
      double c = a*p*p + q;
      par[i] = (Par){a,b,c};
    }
    par[n] = (Par){0,0,0};
    
    vector<double> xs;
    xs.push_back(0);
    xs.push_back(w);
    for (int i=0; i<n; ++i) {
      for (int j=0; j<=n; ++j) {
        if (i == j) continue;
        vector<double> r = crosspoint(par[i],par[j]);
        for (int k=0; k<r.size(); ++k) {
          double x = r[k];
          if (x <= 0 || x >= w) continue;    
          xs.push_back(x);
        }
      }
    }
    sort(xs.begin(),xs.end());
    xs.erase(unique(xs.begin(),xs.end()),xs.end());
    double ans = 0;
    for (int i=0; i<xs.size()-1; ++i) {
      double x1 = xs[i];
      double x2 = xs[i+1];
      double xm = (x1+x2)/2;
      double y_max = 0;
      int id = -1;
      for (int j=0; j<n; ++j) {
        double y = par[j].func(xm);
        if (y_max < y) {
          y_max = y;
          id = j;
        }
      }
      // cout << x1 << " " << x2 << " " << id << endl;
      if (id != -1)
        ans += par[id].integral(x1,x2);
    }
    printf("%.20Lf\n", ans);
  }
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int T = N * A;
  
  if ( T > B ) {
    cout << B << endl;
  }
  else if ( T < B ) {
    cout << T << endl;
  }
  else if ( T == B ) { 
    cout << T << endl;
  }
}

Measured memory_bytes: 256
/*
csc -debug B.cs && mono --debug B.exe <<< "1905"
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var S = cin.NextInt();
        var a = S / 100 >= 1 && S / 100 <= 12;
        var b = S % 100 >= 1 && S % 100 <= 12;

        if (a && b)
            System.Console.WriteLine("AMBIGUOUS");
        else if (a)
            System.Console.WriteLine("MMYY");
        else if (b)
            System.Console.WriteLine("YYMM");
        else
            System.Console.WriteLine("NA");
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


int main(){
    int H, W; cin >> H >> W;
    
    int field[H+1][W+1];
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++) cin >> field[i][j];

    vector<int> ans[H*W+5];
    int id = 0;

    for(int i=1; i<=H; i++){
        if(i%2 == 1){
            for(int j=1; j<=W; j++){
                if(i == H && j == W) continue;

                if(field[i][j]%2 == 1 && j != W){
                    field[i][j]--; field[i][j+1]++;
                    ans[id].push_back(i); ans[id].push_back(j); ans[id].push_back(i); ans[id].push_back(j+1);
                    id++;
                }
                else if(field[i][j]%2 == 1 && j == W){
                    field[i][j]--; field[i+1][j]++;
                    ans[id].push_back(i); ans[id].push_back(j); ans[id].push_back(i+1); ans[id].push_back(j);
                    id++;
                }
            }
        }
        else if(i%2 == 0){
            for(int j=W; j>0; j--){
                if(i == H && j == 1) continue;

                if(field[i][j]%2 == 1 && j != 1){
                    field[i][j]--; field[i][j-1]++;
                    ans[id].push_back(i); ans[id].push_back(j); ans[id].push_back(i); ans[id].push_back(j-1);
                    id++;
                }
                else if(field[i][j]%2 == 1 && j == 1){
                    field[i][j]--; field[i+1][j]++;
                    ans[id].push_back(i); ans[id].push_back(j); ans[id].push_back(i+1); ans[id].push_back(j);
                    id++;
                }
            }
        }
    }

    cout << id << endl;
    for(int i=0; i<id; i++){
        printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<char> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int R = 0, B = 0;
  for (int i = 0; i < N; i++) {
    if(A.at(i) == 'R' ) {
      R++;
    }
    else{
      B++;
    }
  }
  if(R > B) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
pi = 3.1415926535897932384626

def input():
	return sys.stdin.buffer.readline()[:-1]

class Rmax():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [0] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = max(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = 0
		while L<R:
			if R & 1:
				R -= 1
				s = max(s, self.node[R-1])
			if L & 1:
				s = max(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

x1, y1, x2, y2 = map(int, input().split())
n = int(input())
f = [tuple(map(int, input().split())) for _ in range(n)]

if x1 == x2:
	flg = False
	for x, y in f:
		if x == x1 and min(y1, y2) <= y <= max(y1, y2):
			flg = True
	if flg:
		print(abs(y1-y2) * 100 + 10*pi - 20)
	else:
		print(abs(y1-y2) * 100)
elif y1 == y2:
	flg = False
	for x, y in f:
		if y == y1 and min(x1, x2) <= x <= max(x1, x2):
			flg = True
	if flg:
		print(abs(x1-x2) * 100 + 10*pi - 20)
	else:
		print(abs(x1-x2) * 100)
else:
	if x1 > x2 and y1 > y2:
		x1, x2, y1, y2 = x2, x1, y2, y1
		f = [[x[0], x[1], i] for i, x in enumerate(f) if min(x1, x2) <= x[0] <= max(x1, x2) and min(y1, y2) <= x[1] <= max(y1, y2)]
	elif x1 > x2:
		x1, x2 = 10**8-x1, 10**8-x2
		f = [[10**8-x[0], x[1], i] for i, x in enumerate(f) if min(x1, x2) <= 10**8-x[0] <= max(x1, x2) and min(y1, y2) <= x[1] <= max(y1, y2)]
	elif y1 > y2:
		y1, y2 = 10**8-y1, 10**8-y2
		f = [[x[0], 10**8-x[1], i] for i, x in enumerate(f) if min(x1, x2) <= x[0] <= max(x1, x2) and min(y1, y2) <= 10**8-x[1] <= max(y1, y2)]
	#print(f)
	else:
		f = [[x[0], x[1], i] for i, x in enumerate(f) if min(x1, x2) <= x[0] <= max(x1, x2) and min(y1, y2) <= x[1] <= max(y1, y2)]
	n = len(f)
	if n == 0:
		print((abs(x1-x2) + abs(y1-y2)) * 100)
		sys.exit()
	f.sort(key=lambda x: x[1])
	f = [[x[0], i] for i, x in enumerate(f)]
	f.sort(reverse=True)
	st = Rmax(n)
	for x, y in f:
		st.Update(y, st.Get(y, n) + 1)
	num = st.Get(0, n)
	ans = (abs(x1-x2) + abs(y1-y2)) * 100 + num * 5 * pi - num * 20
	if num == min(abs(x1-x2), abs(y1-y2)) + 1:
		ans += 5 * pi
	print("{0:.15f}".format(ans))


Measured memory_bytes: 124380
#include<cstdio>
#include<algorithm>
int main(){
	int a[5]={};
	int k;
	for(int i=0;i<5;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&k);
	if(a[4]-a[0]>k)printf(":(\n");
	else printf("Yay!\n");
	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    int ans = a*b;
    if(ans%2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      sum += 0;
      sum %= 9;
    }
    else if (s[i] == '1') {
      sum += 1;
      sum %= 9;
    }
    else if (s[i] == '2') {
      sum += 2;
      sum %= 9;
    }
    else if (s[i] == '3') {
      sum += 3;
      sum %= 9;
    }
    else if (s[i] == '4') {
      sum += 4;
      sum %= 9;
    }
    else if (s[i] == '5') {
      sum += 5;
      sum %= 9;
    }
    else if (s[i] == '6') {
      sum += 6;
      sum %= 9;
    }
    else if (s[i] == '7') {
      sum += 7;
      sum %= 9;
    }
    else if (s[i] == '8') {
      sum += 8;
      sum %= 9;
    }
    else if (s[i] == '9') {
      sum += 9;
      sum %= 9;
    }
  }
  if (sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    map<int, int> m;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        m[a[i]] += 1;
    }

    for (auto it : m) {
        if (it.first < it.second) ans += it.second - it.first;
        else if (it.first > it.second) ans += it.second;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>

using namespace std;

struct xyz {
    long long b;
    long long c;
};

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<long long> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<xyz> v(m);
    for(int i = 0; i < m; i++) {
        cin >> v[i].b >> v[i].c;
    }
    
    sort(a.begin(), a.end(), [](const long long &x, const long long &y){return x > y;});
    sort(v.begin(), v.end(), [](const xyz &a, const xyz &b){return a.c > b.c;});
    
    int index_a = 0;
    int index_v = 0;
    long long ans = 0;
    int cnt = 0;
    while(cnt < n) {
        if(index_v >= m || a[index_a] > v[index_v].c) {
            ans += a[index_a];
            index_a++;
            cnt++;
        }
        else {
            ans += v[index_v].c * (n - cnt < v[index_v].b ? n - cnt : v[index_v].b);
            cnt += v[index_v].b;
            index_v++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;
    cin >> n;
    vector<ll> dp(n+1,0);
    int h[n];
    REP(i,n)cin>> h[i];
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    COUT(dp[n-1]);
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a[100110]={};

  for(int i=0;i<=n;++i){
    cin>>a[i];
  }
  sort(a,a+n+1);

  int g=1e9;

  for(int i=0;i<n-1;++i){
    g=min(g,__gcd(a[i+2]-a[i+1],a[i+1]-a[i]));
  }

  if(n==1){
    cout << a[1]-a[0] << endl;
  }else
  cout << g << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main ()
{
     signed long long x,a,q,y,z,n,t;
    cin>>n;
    cin>>q;
    getchar();
    queue<int>S[n];
    queue<int>S2[n];
     for(int i=1; i<=q; i++)
    {
        cin>>a;
        if(a==0)
        {
            cin>>t;
            cin>>x;
            S[t].push(x);
        }
        else if(a==1)
        {
            cin>>t;
            //cout<<"S[t] = ";
            if(!S[t].empty())
            {
          cout<<S[t].front()<<endl;
            S2[t].push(S[t].front());
            S2[t].pop();
            }
        }
        else if(a==2)
        {
            cin>>t;
            if(!S[t].empty())
            {
                S[t].pop();
            }
        }
    }
    return 0;
}



Measured memory_bytes: 5124
defmodule Main do
  def main do
    [n, _l] =
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
 
    IO.stream(:stdio, :line)
    |> Enum.take(n)
    |> Enum.map(&String.trim/1)
    |> Enum.sort()
    |> Enum.join()
    |> IO.puts()
  end
end

Measured memory_bytes: 31032
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    ll k;
    cin >> k;

    set<string> pool;

    FOR(i,1,k+1){
      F0R(j,s.length()-i+1){
        pool.insert(s.substr(j,i));
        while(pool.size() > k){
          auto it = pool.end();
          --it;
          pool.erase(it);
        }
      }
    }

    ll cnt = 1;
    for (auto it = pool.begin(); it != pool.end(); it++) {
      if(cnt == k)
        cout << *it << endl;
      cnt++;
    }
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val dic = Array(n) { "" }
    var flg = false

    for (i in 0 until n) {
        val w = sc.next()
        if (w in dic) {
            flg = true
        }
        if (i != 0 && dic[i - 1].last() != w[0]) {
            flg = true
        }
        dic[i] = w
    }
    println(if (!flg) "Yes" else "No")
}


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

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

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

const double PI = acos(-1);



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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int n; cin >> n;
    vvi g(n);
    REP(i, n-1) {
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int root = -1;
    REP(i, n) {
        if (g[i].size() >= 3) {
            root = i;
            break;
        }
    }
    if (root == -1) {
        cout << 1 << endl;
        return 0;
    }

    vector<vector<int>> dp(2, vector<int>(n, INF));

    function<void(int,int)> dfs = [&](int v, int p) {
        int child = 0;
        for (int u : g[v]) if (u != p) ++child;

        if (child == 0) {
            dp[1][v] = 1;
            dp[0][v] = 0;
            return;
        }

        int sum = 0, ma = -1;
        for (int u : g[v]) {
            if (u == p) continue;
            dfs(u, v);
            sum += dp[1][u];
            if (dp[0][u] != INF) {
                chmax(ma, dp[1][u] - dp[0][u]);
            }
        }

        if (ma == -1) {
            dp[1][v] = sum;
            return;
        }

        if (child == 1) {
            dp[1][v] = sum;
            dp[0][v] = sum - ma;
            return;
        }

        dp[1][v] = sum - ma;
    };

    dfs(root, -1);

    int ans = dp[1][root];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12416
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

struct P {
    int ch, idx, nidx;
    P () { }
    ~P () {}
    P (int a, int b, int c) : ch(a), idx(b), nidx(c) {}
};

const int INF = 1 << 29;

string A;

int main() {
    cin >> A;
    const int N = A.size();

    int z[26]; fill(z, z+26, 0);
    vector<P> w[26];
    for (int j = 0; j < 26; ++j) {
        w[j].emplace_back(-1, INF, -1);
    }
    for (int j = N-1; j >= 0; --j) {
        int v = INF;
        int c = -1;
        for (int k = 0; k < 26; ++k) {
            if (z[k] < v) {
                c = k;
                v = z[k];
            }
        }
        P nex = *w[c].rbegin();
        w[A[j]-'a'].emplace_back(c, j, nex.idx);
        z[A[j]-'a'] = v+1;
    }

    int t = -1;
    for (int j = 0; j < 26; ++j) {
        if (t == -1 || z[j] < z[t]) {
            t = j;
        }
    }

    while (true) {
        cout << (char)('a'+t);

        if (w[t].rbegin()->idx == INF) {
            break;
        }

        P p = *w[t].rbegin();
        for (int j = 0; j < 26; ++j) {
            while (w[j].rbegin()->idx <= p.idx) {
                w[j].pop_back();
            }
        }
        t = p.ch;
    }
    cout << endl;
    return 0;
}


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

int main() {
    ll A;
    long double B;
    cin >> A;
    cin >> B;

    ll res = A * B;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3744
package main
import (
  "fmt"
)

func main() {
  var N, sum int
  fmt.Scan(&N)
  B := make([]int, N+1)
  for i := 1; i < N; i++ {
    fmt.Scan(&B[i])
  }
  B[0] = B[1]
  B[N] = B[N-1]
  for i := 0; i < N; i++ {
    if B[i] < B[i+1] {
      sum += B[i]
    } else {
      sum += B[i+1]
    }
  }
  fmt.Println(sum)
}


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

int main(){
 string S;

 cin >> S;


if(S == "Sunny"){
    cout << "Cloudy" << endl;
}else if(S == "Cloudy"){
    cout << "Rainy" << endl;
}else{
    cout << "Sunny" << endl;
}

}

Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))

inc = 0
cnt = 0
for i in range(n-1):
    if inc == -1 and L[i] < L[i+1]:
        cnt += 1
        inc = 0
    elif inc == 1 and L[i] > L[i+1]:
        cnt += 1
        inc = 0
    elif inc == 0 and L[i] > L[i+1]:
        inc = -1
    elif inc == 0 and L[i] < L[i+1]:
        inc = 1
print(cnt+1)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll n;
    cin>>n;
    map<string,ll> mp;
    string s;
    rep(i,n){
        cin>>s;
        mp[s];
    }
    ll cnt=0;
    for(auto x:mp) cnt++;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 19120
function main()
	N=parse(Int,readline())
	ca=cb=cab=0
	ans=0
	for _=1:N
		s=chomp(readline())
		n=length(s)
		for i=2:n
			if s[i-1]=='A'&&s[i]=='B'
				ans+=1
			end
		end
		if s[1]=='B'
			cb+=1
			if s[end]=='A'
				cab+=1
			end
		end
		if s[end]=='A'
			ca+=1
		end
	end
	if cab>0
		ca-=cab
		cb-=cab
		ans+=cab-1
		if ca>0||cb>0
			ans+=1
		end
	end
	println(ans+min(ca,cb))
end
main()


Measured memory_bytes: 115856
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

int main(){
	int n;
	while(cin>>n){
		int i,j,k,l,a=0;
		for(i=0;i<=9;i++){
			for(j=0;j<=9;j++){
				for(k=0;k<=9;k++){
					for(l=0;l<=9;l++){
						if(i+j+k+l==n)a++;
					}
				}
			}
		}
		cout<<a<<endl;
	}

    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;

int main() {
  int N; cin >> N;
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; i++) cin >> P[i], P[i]--; 
  for (int i = 0; i < N; i++) cin >> Q[i], Q[i]--;

  map<vector<int>, int> ord;
  int iter = 0;

  vector<int> v(N);
  for (int i = 0; i < N; i++) v[i] = i;

  do {
    ord[v] = iter++;
  } while (next_permutation(v.begin(), v.end()));
  
  cout << abs(ord[P] - ord[Q]) << endl;
}


Measured memory_bytes: 5248
#binarysearch.rb
#
def binary_search(arr ,key ,n)
  left=0
  right=n

  while left < right
    mid = (left+right)/2
    if(arr[mid]==key)
      return(mid)
    elsif key < arr[mid]
      right = mid
    else
      left = mid+1
    end
  end
  return(-1)
end

s=Array.new(100000)
t=Array.new(50000)

n=STDIN.gets.split[0].to_i
str=STDIN.gets.split
0.upto(n-1) {|i|
  s[i] = str[i].to_i
} 
q=STDIN.gets.split[0].to_i
str=STDIN.gets.split
0.upto(q-1) {|i|
  t[i] = str[i].to_i
} 
c=0
0.upto(q-1) {|i|
  ret=binary_search(s,t[i],n)

  if ret > -1 then
    #printf("%d %d\n",t[i],ret)
    c+=1
  end

} 
puts c

Measured memory_bytes: 17284
//Atcoder 177C
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;

int MOD=1000000007;

int32_t main(){
	int n;
	cin >> n;
	int arr[n];
	int sum=0;
	for(int i=0;i<n;i++){
		cin >> arr[i];
		sum=(sum+arr[i])%MOD;
	}
	int answer=0;
	for(int i=0;i<n;i++){
		sum=(sum-arr[i]);
		if(sum<0) sum+=MOD;
		answer=(answer+(arr[i]*sum)%MOD)%MOD;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 5204
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int K;
    cin>>K;

    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout<<A[K-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define dl double
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL)
#define cases ll t; cin>>t; while(t--)
#define rep1(qq,pp) for(ll i=qq;i<pp;i++)
#define rep2(qqq,ppp) for(ll i=qqq;i>=ppp;i--)
#define nl "\n"
#define Y cout<<"Yes\n"
#define N cout<<"No\n"
//cout<<fixed<<setprecision(13);

int main(){
	faster;

    int ans=0;
	string s;
	
	cin>>s;
	
	rep1(0,s.length()){
	    ans+=(s[i]-48);
	}
	
	if(ans%9) N;
	else Y;
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <vector>

char getInitial(std::string const& word);
 
int main() {
    std::vector<std::string> contestName;
    std::string word;
    while(std::cin >> word) {
        contestName.push_back(word);
    }
    
    std::string abbreviation;
    for(std::string tmp :contestName) {
        abbreviation += getInitial(tmp);
    }
    
    std::cout << abbreviation << std::endl;
}

char getInitial(std::string const& word) {
    return word.at(0);
}

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        long N = sc.nextLong();
        long P = sc.nextLong();

        System.out.println(solve(N, P));
    }

    private static long solve(long N, long P) {
        long count = 1;
        List<Pair> primeList = primeFactorize(P);
        for (int i=0; i<primeList.size(); i++) {
            Pair p = primeList.get(i);
            System.err.println("prime=" + p.first + " * " + p.second);

            if (p.second >= N) {
                // count *= p.first * (p.second / N);
                count *= Math.pow(p.first,  (p.second / N));
            }
        }

        return count;
    }

    private static List<Pair> primeFactorize(Long N) {
        List<Pair> list = new ArrayList();


        for (long p=2; p*p <= N; p++) {
            if (N%p != 0) continue;
            int num = 0;
            while (N%p == 0) {
                num++;
                N /= p;
            }

            list.add(new Pair(p, num));
        }
        if (N != 1) {
            list.add(new Pair(N, 1));
        }

        return list;
    }

    public static class Pair {
        long first;
        long second;

        public Pair(long a, long b) {
            this.first = a;
            this.second = b;
        }
    }
}

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

int main() {
  int H,W;
  string a;
  vector<char> slice(W+2);
  cin >> H >> W ;
  vector<vector<char>> mat(H+2,vector<char>(W+2));

  for (int i =0; i < H+2 ;i++){
    if( i != 0 && i != H+1 ){
      cin >> a ;
    for(int s =0;s < W+2;s++){
      if (s == 0){
        slice.at(s) = '#';
        continue;
      }
      else if (s == W+1){
        slice.at(s) = '#';
        break;
      }
      slice.at(s) = a.at(s-1);
    }
    }

    for(int j =0 ; j < W+2 ;j++){
      if (i == 0){   
        mat.at(i).at(j) = '#';
        continue;
      }
       else if (i == H+1){       
        mat.at(i).at(j) = '#';
        continue;
      }
       else if(j == 0 ){
        mat.at(i).at(j) = '#';
        continue;
      }
       else if(j == W+1 ){
        mat.at(i).at(j) = '#';
        continue;
      }
      mat.at(i).at(j) = slice.at(j);
     
    }
  }
    
  for (int k = 0;k < H+2;k++){
    for (int l = 0;l < W+2;l++){
      if(l == W+1){
        cout << mat.at(k).at(l) << endl;
        break;
      }
      cout << mat.at(k).at(l) ;

    }
  }
}



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

void Constraints(int x,int i) //制約関数の宣言
{
  if(1<=x&&x<=10000&&i<=10000){}
  else
  {}
}

int main(void)
{
  int x=1;
  int i=0;
  while(x!=0){
    i++;
    scanf("%d",&x);
    Constraints(x,i);
    if(x!=0){
      printf("Case %d: %d\n",i,x);
    }
  }
	return 0;
}


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

int main(){
  int x;
  cin >>x;
  
  int n500, n5;
  n500=x/500;
  n5= (x%500)/5;
  cout <<n500*1000+n5*5<<endl;
    
 
}

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

int main(){
  string str;
  while(cin >> str, str!="-"){
    int m; cin >> m;
    for(int i=0; i<m; i++){
      int h; cin >> h;
      str = str.substr(h) + str.substr(0,h);
    }
    cout << str << endl;
  }
  return 0;
}

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

int main() {
  ll h, w;
  cin >> h >> w;
  if (min(h,w) == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll n = h*w;
  ll ans = (n+1)/2;
  cout << ans << endl;
  return 0;
}

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

// ローリングハッシュ
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
};

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

    // ロリハ
    RollingHash rh(S);

    // 二分探索判定
    auto check = [&](int d) -> bool {
        map<pair<long long, long long>, int> ma;
        for (int i = 0; i + d <= N; ++i) {
            auto p = rh.get(i, i+d);
            if (ma.count(p)) {
                if (i - ma[p] >= d) return true;
            }
            else ma[p] = i;
        }
        return false;
    };

    // 二分探索
    int left = 0, right = N/2 + 1;
    while (right - left > 1) {
        int mid = (left + right) >> 1;
        if (check(mid)) left = mid;
        else right = mid;
    }
        
    cout << left << endl;
}

Measured memory_bytes: 4052
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

from math import sqrt,cos, pi

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

def calcAngle(h,m): 

        if (h == 12): 
            h = 0
        if (m == 60): 
            m = 0
          
        # Calculate the angles moved by  
        # hour and minute hands with  
        # reference to 12:00 
        hour_angle = 0.5 * (h * 60 + m) 
        minute_angle = 6 * m 
          
        # Find the difference between two angles 
        angle = abs(hour_angle - minute_angle) 
          
        # Return the smaller angle of two  
        # possible angles 
        angle = min(360 - angle, angle) 
          
        return angle 

a,b, h, m = multi_int_input()

angle = calcAngle(h, m)*(pi/180)
# angle = calcAngle(h, m)
# print(angle)

print(sqrt( a*a + b*b - 2*a*b*cos(angle)))

Measured memory_bytes: 9932