akhauriyash/Code-Regression huggingface dataset:
//Circle Pond

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int inf = 1000000000;

int main (){
    int R;cin>>R;
    const double PI=3.14159265358979323846;
    printf("%.16f", R*2*PI);
    return 0;
}

Measured memory_bytes: 3708
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
long long int ncr(long long int n,long long int r){
  long long int i,ans;
  ans=1;
  for(i=1;i<=(n-r);i++){
    ans*=(n-i+1);
    ans/=i;
  }
  return ans;
}
int main(void){
  long long int n,p;
  cin>>n>>p;

  long long int res,res2,res3;
  res=res2=res3=0;
  long long int i,a, ki,gu;
  ki=gu=0;
  for(i=0;i<n;i++){
    cin>>a;
    if(a%2==0) gu++;
    else ki++;   
  }

  for(i=0;i<=gu;i++){
    res+=ncr(gu,i);
  }
  for(i=0;i<=ki;i+=2){
    res2+=ncr(ki,i);
  }
  for(i=1;i<=ki;i+=2){
    res3+=ncr(ki,i);
  }
  
  if(p==0){
    cout<<res*res2<<endl;
  }
  else{
    cout<<res*res3<<endl;
  }

  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int flag = 0;
    int cnt = 1;
    int f, a;
    cin >> f;
    for(int i=0; i<N-1; i++)
    {
        cin >> a;
        // flag 0 : =
        //      1 : <
        //      2 : >
        if (flag==0)
        {
            // 変化なしの場合 0
            // 次で順序関係が変化したら
            if(a > f) flag = 1; // 単調増加
            if(a < f) flag = 2; // 単調減少
            
        }
        else if (flag==1)
        {
            if(a < f)
            {
                // 単調増加が崩壊
                cnt++;
                flag = 0;
            }
        }
        else
        {
            if(a > f)
            {
                // 単調減少が崩壊
                cnt++;
                flag = 0;
            }
        }
        f = a;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

int solve(string s[], int H, int W, int i, int j);

int main(void) {

    int N;
    cin >> N;

    vector<int> cnt(100, 0);

    rep(i, N) {
        int j = i+1;
        int tail = j % 10;
        while(j > 9) j /= 10;
        int head = j;
        int idx = head * 10 + tail;
        cnt[idx]++;
        // cout << idx << endl;
    }

    int ans = 0;
    for(int i=1; i<10; i++) {
        for(int j=1; j<10; j++) {
        // for(int j=i; j<10; j++) {
            int x = i*10 + j;
            int y = j*10 + i;
            ans += cnt[x] *cnt[y];
        }
    }

    cout << ans;
    // cout << endl <<endl;
    // rep(i, 100) {
    //     cout << cnt[i] << endl;
    // }
    return 0;
}


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


typedef complex<double> P;
typedef vector<P> G;

#define EPS			(1e-10)
#define PI			(3.14159265358979323846)


#define X(a)		( (a).real() )
#define Y(a)		( (a).imag() )
#define EQ(a,b)		( -EPS<(a)-(b) && (a)-(b)<EPS )
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )

// 3ツ点ツづ個暗環置ツ甘鳴係
int ccw(P a, P b, P c)
{
	b -= a; c -= a;
	if(cross(b, c) > 0)   return +1;	// counter clockwise
	if(cross(b, c) < 0)   return -1;	// clockwise
	if(dot(b, c) < 0)     return +2;	// c--a--b on line
	if(norm(b) < norm(c)) return -2;	// a--b--c on line
	return 0;
}

// ツ静シツ閉ェツづ静シツ閉ェツづ個古ーツ債キツ板サツ津ィ
bool intersectSS(P a, P b, P c, P d)
{
	return	ccw(a,b,c)*ccw(a,b,d) <= 0 &&
			ccw(c,d,a)*ccw(c,d,b) <= 0;
}

P crosspointLL(P a, P b, P c, P d)
{
	double det=cross(d-c,b-a);
	assert(!(abs(det)<EPS));

	return a + (b-a) * cross(d-c,c-a)/det;
	
	// u=b-a  ->  a + tu ( t = cross(d-c,c-a)/det )
	// v=d-c  =>  c + sv ( s = cross(b-a,c-a)/det )
}

int main()
{
	P p[6];
	while(cin >> X(p[0]) >> Y(p[0]) >> X(p[1]) >> Y(p[1]), X(p[0])||Y(p[0])||X(p[1])||Y(p[1]))
	{
		cin >> X(p[2]) >> Y(p[2]) >> X(p[3]) >> Y(p[3]);
		cin >> X(p[4]) >> Y(p[4]) >> X(p[5]) >> Y(p[5]);

		bool crs = true;
		for(int i=0; i<6; i+=2)
		{
			if(!intersectSS(p[i],p[i+1],p[(i+2)%6],p[(i+3)%6]))
			{
				crs=false; break;
			}

			if(EQ(cross(p[i+1]-p[i],p[(i+3)%6]-p[(i+2)%6]),0.0))
			{
				crs=false; break;
			}
		}

		if(crs)
		{
			P c[3];

			for(int i=0; i<6; i+=2)
			{
					c[i/2] = crosspointLL(p[i],p[i+1],p[(i+2)%6],p[(i+3)%6]);
			}
			
			double s = abs(cross(c[1]-c[0],c[2]-c[0]))/2;

			if(EQ(s,0.0))
			{
				cout << "kyo" << endl;
			}
			else if(s<100000)
			{
				cout << "syo-kichi" << endl;
			}
			else if(s<1000000)
			{
				cout << "kichi" << endl;
			}
			else if(s<1900000)
			{
				cout << "chu-kichi" << endl;
			}
			else
			{
				cout << "dai-kichi" << endl;
			}
		}
		else
		{
			cout << "kyo" << endl;
		}
	}
}

Measured memory_bytes: 0
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        int[] n = IO.INT(' ');
        IO.WRITE(GCD.GET(n[0], n[1]));
        IO.FLUSH();
    }
}
#region GCD
namespace LIB
{
    public class GCD
    {
        public static int GET(int x, int y)
        {
            int a = Math.Max(x, y);
            int b = Math.Min(x, y);
            while (b != 0) { a %= b; if (b > a) { int z = a; a = b; b = z; } }
            return a;
        }
    }
}
#endregion
namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

Measured memory_bytes: 9648
#include <iostream>
#include <cstdlib>
using namespace std;
 //Compiler version g++ 6.3.0
 
bool check(int t,int x,int y){
	int xy = x + y;
	if(xy == 1&&t == 3){
		return true;
	}
	t -= xy;
	t = abs(t);
	if(!(t % 4)){
		return true;
	}else{
		return false;
	}
}

 int main()
 {
 	int n;
 	cin >> n;
 	int t[n],x[n],y[n];
 	bool b[n] = {false};
 	for(int i = 0;i < n;i++){
 		cin >> t[i]>>x[i]>>y[i];
 	}
 	
 	b[0] = check(t[0],x[0],y[0]);
 	
 	int dt, dx, dy;
 	
 	for(int i = 1;i < n;i++){
 		dt = abs(t[i] - t[i-1]);
 		dx = abs(x[i] - x[i-1]);
 		dy = abs(y[i] - y[i-1]);
 		
 		b[i] = check(dt, dx, dy);
 	}
 	
 	for(bool i : b){
 		if(!i){
 			cout << "No" << endl;
 			return 0;
 		}
 	}
 	cout << "Yes" << endl;
 	return 0;
 }

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a,b,c,d;
  a=(int)(s.at(5)-'0');
  b=(int)(s.at(6)-'0');
  c=(int)(s.at(8)-'0');
  d=(int)(s.at(9)-'0');
  if(10*a+b>=5){cout<<"TBD";}
  else{cout<<"Heisei";}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int H,W,i,j;
  cin >> H >> W;
  string s[H];
  for (i=0;i<H;++i) {
    cin >> s[i];
  }
  for (i=0;i<H;++i) {
    for (j=0;j<W;++j) {
      if (s[i][j]=='#') {
        if ((i==0 || s[i-1][j]=='.') && (i==H-1 || s[i+1][j]=='.') && (j==0 || s[i][j-1]=='.') && (j==W-1 || s[i][j+1]=='.')) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int h,w;
    Scd2(h,w);
    char s[64][64] = {};
    bool t[62][62] = {};

    Rep(i,h){
        Scs(s[i+1]+1);
    }

    int k = 0;
    Rep(i,h)Rep(j,w){
        k += s[i+1][j+1] == '#';
    }

    using pii = pair<int,int>;
    using piii = pair<pii,int>;
    deque< piii > q;
    q.push_back( piii(pii(1,1),1) );
    t[1][1] = true;

    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};
    int ans = -1;
    while( !q.empty() ){
        int y = q.front().first.first;
        int x = q.front().first.second;
        Rep(i,4){
            if( !t[y+dy[i]][x+dx[i]] && s[y+dy[i]][x+dx[i]] == '.' ){
                t[y+dy[i]][x+dx[i]] = true;
                q.push_back(piii(pii(y+dy[i],x+dx[i]),q.front().second+1));
            }
        }
        if( y == h && x == w ){
             ans = w*h - k - q.front().second;
        }
        q.pop_front();
    }

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


    return 0;
}



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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main(int argc, char const* argv[])
{
  string s;
  cin>>s;

  REP(i,s.size()) {
    cout << "x";
  } cout << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
cnt = 0
if n < 105:
    print(0)
    quit()
elif n == 105:
    print(1)
    quit()
else:
    ans = 1
    for i in range(107, n+1, 2):
        cnt = 0
        for j in range(1, i+1):
            if i % j == 0:
                cnt += 1
        if cnt == 8:
            ans += 1
    print(ans)


Measured memory_bytes: 38640
def main():
    ans = 0
    n = int(input())
    l = list(map(int, input().split()))
    for i in range(n-1):
        if l[i] == i+1:
            l[i] = l[i+1]
            l[i+1] = i+1
            ans += 1
    if l[n-1] == n:
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14008
N=int(input())
Hi=list(map(int,input().split()))

for i in range(N-1):
    if Hi[i] < Hi[i+1]:
        Hi[i+1]-=1
    
    if Hi[i] == Hi[i+1]:
        pass

    if Hi[i] > Hi[i+1] :
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 20784
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int countAB(string s) {
    int n = 0;
    for (int i = 1; i < s.length; i++) {
        if (s[i-1] == 'A' && s[i] == 'B') n++;
    }
    return n;
}

int calc(string[] a) {
    int ans = a.map!(countAB).sum;

    int xa = 0;
    int bx = 0;
    int ba = 0;
    foreach (s; a) {
        auto front = s.front;
        auto last = s[$-1];
        if (front == 'B' && last == 'A') ba++;
        else if (front == 'B') bx++;
        else if (last == 'A') xa++;
    }

    if (xa > 0) xa--;
    else if (ba > 0) ba--;
    else return ans;

    if (ba > 0) {
        ans += ba;
        ba = 0;
    }

    // 末尾が A で終わっている状態
    while (xa > 0 || bx > 0) {
        if (bx == 0) break;

        ans++;
        bx--;

        int k = min(bx, xa);
        if (k == 0) break;
        ans += k;
        bx -= k;
        xa -= k;

        if (xa == 0) break;
        xa--;
    }
    return ans;
}

void main() {
    int n = readint;
    string[] a;
    for (int i = 0; i < n; i++) a ~= read!string;
    writeln(calc(a));
}



Measured memory_bytes: 2428
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let p: i64 = get();
    let q: i64 = get();
    let c: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let mut u: Vec<_> = (0 .. n).map(|i| c[i] + p * (i as i64 - q)).collect();
    u.sort();
    let mut uacc = vec![0; n + 1];
    for i in 0 .. n {
        uacc[i + 1] = uacc[i] + u[i];
    }
    let csum: i64 = c.iter().sum();
    let mut ma = -1 << 62;
    for xone in 0 .. n as i64 + 1 {
        let mut tot = 0;
        tot += xone * (xone - 1) * p;
        tot -= uacc[xone as usize];
        tot += csum;
        ma = max(ma, tot);
    }
    println!("{}", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 23340
import java.util.Scanner;

public class Main {

	static final long MOD = 1000000007;
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int S = scan.nextInt();
		int W = scan.nextInt();

		System.out.println(W >= S ? "unsafe" : "safe");

	}
}

Measured memory_bytes: 35832
#include<stdio.h>
#define N 10005
int search(int *,int ,int);
  int main()
{
  int n,A[N],q,B,found = 0,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&B);
    
      if(search(A,n,B)) found++;
    }
  printf("%d\n",found);

  return 0;
}

int search(int A[] ,int n, int B)
{
  int k=0;
  A[n] = B;
  while(A[k] != B)k++;
  return k !=n;
    }



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll n,m;
  cin >> n >> m;
  ll x[n];
  ll y[m];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> y[i];
  }
  ll dx[n-1];
  ll dy[m-1];
  for (ll i = 1; i < n; i++) {
    dx[i-1] = x[i] - x[i-1];
  }
  for (ll i = 1; i < m; i++) {
    dy[i-1] = y[i] - y[i-1];
  }
  ll ans = 0;

  ll tmp = 0;
  for (ll i = 0; i < n-1; i++) {
    ll res = (i + 1) * (n - i - 1);
    res %= Mod;
    res *= dx[i];
    res %= Mod;
    tmp += res;
    tmp %= Mod;
  }

  for (ll i = 0; i < m-1; i++) {
    ll res = (i + 1) * (m - i - 1);
    res %= Mod;
    res *= tmp;
    res %= Mod;
    res *= dy[i];
    res %= Mod;
    ans += res;
    ans %= Mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6720
n = int(input())
a = list(map(int, input().split()))
a_min = [0] * (n + 1)
a_min[n] = a[n]
for i in range(n - 1, -1, -1):
    a_min[i] = a[i] + a_min[i + 1]

b = [1]
for i in range(n):
    tmp = b[i] - a[i]
    b.append(min(tmp * 2, a_min[i + 1]))
    if tmp < 1:
        print(-1)
        break
else:
    if b[n] != a[n]:
        print(-1)
    else:
        print(sum(b))


Measured memory_bytes: 22244
N = int(input())
A = list(map(int, input().split()))
A.sort()
old = A[0]
ans = 0
a = 1
for i in range(1, N):
  if A[i] == old: 
    a += 1
  else:
    if old > a:
      ans += a
    elif old < a:
      ans += a - old
    old = A[i]
    a = 1
if old > a:
  ans += a
elif old < a:
  ans += a - old
print(ans)

Measured memory_bytes: 14268
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  	int N,K,X,Y,ans=0;
  	cin >> N >> K >> X >> Y;
  	for(int i=1;i<=N;++i){
      if(i<=K)ans+=X;else ans+=Y;
    }
    cout << ans << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N, K;
vector<int> L, R;

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    cin >> N >> K;
    while(N--){
        int x;
        cin >> x;
        if(x <= 0){
            L.push_back(-x);
        } else {
            R.push_back(x);
        }
    }

    reverse(allof(L));

    int ans = 2e9;
    if((int)L.size() >= K){
        ans = L[K - 1];
    }

    if((int)R.size() >= K){
        ans = R[K - 1];
    }

    for(int a = 0; a < (int)L.size() && a < K - 1; a++){
        if(K - a - 2 < (int)R.size()){
            ans = min(ans, L[a] * 2 + R[K - a - 2]);
        }
    }

    for(int a = 0; a < (int)R.size() && a < K - 1; a++){
        if(K - a - 2 < (int)L.size()){
            ans = min(ans, R[a] * 2 + L[K - a - 2]);
        }
    }

    cout << ans;
}


Measured memory_bytes: 1020
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc  = new Scanner(System.in);
      	String s = sc.next();
      	String t = "";
      	for(int i = 0; i < s.length(); i++){
        	if(s.charAt(i) == '0') t+= "0";
          	else if(s.charAt(i) == '1') t+= "1";
          	else if(s.charAt(i) == 'B' && t.length()>=1)
              t = t.substring(0, (t.length()-1));
    
        }
      
      	System.out.println(t);
    }
}

Measured memory_bytes: 38576
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7){cout<<"YES"<<endl;return 0;}
    if(a==5&&b==7&&c==5){cout<<"YES"<<endl;return 0;}
    if(a==7&&b==5&&c==5){cout<<"YES"<<endl;return 0;}
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin >> n >> m;
  vector<int> a(m),b(m),c(m);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    for(int j=0;j<b[i];j++){
      int x;cin >> x;
      x--;
      c[i]+=(1<<x);
    }
  }
  vector<int> dp(1<<n,1e9);
  dp[0]=0;
  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<m;j++){
      dp[i|c[j]]=min(dp[i|c[j]],dp[i]+a[j]);
    }
  }
  if(dp[(1<<n)-1]==1e9){
    cout << -1 << endl;
  }
  else{
    cout << dp[(1<<n)-1] << endl;
  }
}

Measured memory_bytes: 256
//2018.09.15 2min

#include <iostream>
using namespace std;

int main() {

    int N;
    cin >> N;

    int i,j;
    int a[N];
    for(i=0;i<N;i++){
        cin >> a[i];
    }

    int alice=0, bob=0;
    int maxv=0;
    for(i=0;i<N;i+=2){
        for(j=0;j<N;j++){
            maxv = max(maxv,a[j]);
        }
        alice += maxv;
        for(j=0;j<N;j++){
            if(maxv==a[j]){
                a[j]=0;
                break;
            }
        }

        maxv=0;
        for(j=0;j<N;j++){
            maxv = max(maxv,a[j]);
        }
        bob += maxv;
        for(j=0;j<N;j++){
            if(maxv==a[j]){
                a[j]=0;
                break;
            }
        }

        maxv=0;

    }

    cout << alice-bob << endl;

    return 0;
}

Measured memory_bytes: 256
#C
N = int(input())
H = list(map(int, input().split()))
A = []
B = []
ans = 0

for i in range(0,N-1):
    if H[i] >= H[i+1]:
        A.append(1)
    else:
        A.append(0)
        
for j in range(0,N-1):
    if A[j] == 1:
        ans += 1
        B.append(ans)
    else:
        ans = 0
        
print(0 if len(B) == 0 else max(B))

Measured memory_bytes: 14224
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BJudgeStatusSummary {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      map<string, int> mp;
      rep(i, n) {
        string s; cin >> s;
        mp[s]++;
      }
      cout << "AC x " << mp["AC"] << endl;
      cout << "WA x " << mp["WA"] << endl;
      cout << "TLE x " << mp["TLE"] << endl;
      cout << "RE x " << mp["RE"] << endl;
    }
};

signed main() {
  BJudgeStatusSummary solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3676
from fractions import gcd

a, b, c, d = map(int, input().split())


def cnt_div(a, b, x):
    q, r = divmod(a, x)

    if r == 0:
        m = q - 1
    else:
        m = q

    n = b // x

    return n - m


num_c = cnt_div(a, b, c)
num_d = cnt_div(a, b, d)
lcm = int((c * d) / gcd(c, d))
num_c_d_gcd = cnt_div(a, b, lcm)

print((b - a + 1) - (num_c + num_d - num_c_d_gcd))


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

int time(int h,int m,int s){
	while(s>=60){
		s-=60;
		m++;
	}
	while(m>=60){
		m -=60;
		h++;
	}
	cout<<"0"<<h<<":";
	if(m>=10){
		cout<<m<<":";
	}else{
		cout<<"0"<<m<<":";
	}
	if(s>=10){
		cout<<s<<endl;
	}else{
		cout<<"0"<<s<<endl;
	}
	return 0;
}
int main(){
	int h,m,s;
	while(cin>>h>>m>>s){
		if(h==-1 && m==-1 && s==-1) break;
		int t=7200-h*3600-m*60-s;
		s=t%60;
		t -= s;
		m=t/60;
		t -=m*60;
		h=t;
		time(h,m,s);
		h*=3;
		m*=3;
		s*=3;		
		time(h,m,s);
	}
	return 0;
}

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

int main() {
    int N, A[100];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    for (int i = 0; i < N; ++i) {
        if (i) cout << ' ';
        cout << A[i];
    }
    cout << endl;

    for (int i = 1; i < N; ++i) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            --j;
        }
        A[j + 1] = v;
        for (int k = 0; k < N; ++k) {
            if (k) cout << ' ';
            cout << A[k];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	int X, A, B;
	cin >> X >> A >> B;
	int Y = -A + B;
	if (Y <= 0) cout << "delicious" << endl;
	else if (Y <= X) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include "stdio.h"

int main(void){
  char S[10];
  int count = 0;
  
  scanf("%s", S);

  if(S[0] == 'A'){
    count++;
  }
  if(S[1] == 'A'){
    count++;
  }
  if(S[2] == 'A'){
    count++;
  }

  if(count == 0 || count == 3){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  
  return 0;
}



Measured memory_bytes: 128
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N = int(input())
p = []
for i in range(N):
    x, y = list(map(int, input().split()))
    p.append([x, y])

def intersection(x1, y1, x2, y2, R):
    L2 = (x2 - x1)**2 + (y2 - y1)**2

    if 4*R**2 < L2: return [INF, INF, INF, INF]

    p1x = (x1 + x2) / 2.0 - math.sqrt(4.0 * R ** 2 / L2 - 1) * (y2 - y1) / 2.0
    p1y = (y1 + y2) / 2.0 + math.sqrt(4.0 * R ** 2 / L2 - 1) * (x2 - x1) / 2.0
    p2x = (x1 + x2) / 2.0 + math.sqrt(4.0 * R ** 2 / L2 - 1) * (y2 - y1) / 2.0
    p2y = (y1 + y2) / 2.0 - math.sqrt(4.0 * R ** 2 / L2 - 1) * (x2 - x1) / 2.0

    return [p1x, p1y, p2x, p2y]

M = 750
m = 0
R = 375

for l in range(100):
    for i in range(N):
        for j in range(i+1, N):
            pp = intersection(p[i][0], p[i][1], p[j][0], p[j][1], R)
            flag = 1
            if pp[0] == INF:
                flag = 0
                continue
            else:
                for k in range(N):
                    if k != i and k != j:
                        if (pp[0] - p[k][0]) ** 2 + (pp[1] - p[k][1]) **2 > R ** 2:
                            flag = 0
                            break

                if flag == 0:
                    flag = 1
                    for k in range(N):
                        if k != i and k != j:

                            if (pp[2] - p[k][0]) ** 2 + (pp[3] - p[k][1]) ** 2 > R ** 2:
                                flag = 0
                                break

            if flag == 1:
                M = R
                R = (m + R) / 2.0
                break

        if flag == 1:
            break

    if flag == 0:
        m = R
        R = (R + M) / 2.0

    # print(R,flag)

print(R)




Measured memory_bytes: 77552
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 2019


def resolve():
    L, R = map(int, input().split())

    for i in range(L, R + 1):
        if i % mod == 0:
            print(0)
            break
    else:
        res = f_inf
        for i in range(L, R):
            for j in range(L + 1, R + 1):
                calc = i * j % mod
                res = min(res, calc)

        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
///A drunk man will find his way home, but a drunk bird may get lost forever...i
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define pf push_front
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define mp make_pair
//const int mx = 2000 * 100;
int t[110];
int32_t main(){		
	ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int n, k = 0, a;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		t[a]++;
		k = max(k , a);
	}
	if(k % 2 == 0){
		for(int i = k; i > k / 2; i--){
			if(t[i] < 2){
				cout << "Impossible" << endl;
				return 0;
			}
			t[i] -= 2;
		}
		if(t[k / 2] < 1){
			cout << "Impossible" << endl;
			return 0;
		}
		t[k / 2]--;
		for(int i = 1; i <= 100; i++){
			if(t[i] && i < k / 2 + 1){
				cout << "Impossible" << endl;
				return 0;
			}
		}
		cout << "Possible" << endl;
		return 0;
	}
	for(int i = k; i >= (k + 1)/ 2; i--){
		if(t[i] < 2){
			cout << "Impossible" << endl;
			return 0;
		}
		t[i] -= 2;
	}
	for(int i = 1; i <= 100; i++){
		if(t[i] && i < (k + 1) / 2 + 1){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	cout << "Possible" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] data = S.toCharArray();
        int current = 0;
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < data.length; i++) {
            if (data[i] == '(') {
                current += 1;
            }
            if (data[i] == ')') {
                current -= 1;
            }
            sb.append(data[i]);
            if (current < 0) {
                sb.insert(0, '(');
                current += 1;
            }
        }
        for (int i = 0; i < current; i++) {
            sb.append(')');
        }
        System.out.println(sb.toString());
    }
}


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

ll N ;
cin >> N ;
ll ans = 10e18 ;
  for (ll i = 1 ; i*i<=N ; i++ ){
    if(N%i == 0 ) {
     ll j = N/i ;
      ans = min(ans,j+i-2);
  }
  }
cout << ans <<endl ;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

void dfs(string s, char mx, int n) {
    if ( s.length() == n ) {
        cout << s.c_str() << endl;
    }
    else {
        for ( char c = 'a'; c <= mx; ++c ) {
            dfs(s+c, ((c==mx) ? (char)(mx + 1) : mx), n);
        }
    }
}

int main(){
    int n;
    cin >> n;
    dfs("", 'a', n);
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>

int main(void)
{
	int wei[10]={1,2,4,8,16,32,64,128,256,512},kai[10];
	int w,i,j;
	while(scanf("%d",&w)!=EOF)
	{
		i=9;  j=0;
		while(0==0)
		{
			if(w-wei[i]>0){
				w-=wei[i];
				kai[j]=wei[i];
				j++;
			}
			else if(w-wei[i]==0){
				kai[j]=wei[i];
				for(i=j;i>0;i--)
					printf("%d ",kai[i]);
				printf("%d\n",kai[0]);
				break;
			}

			i--;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279


void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int gcd(int a, int b)
{
    int c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}
int main(void){
	
	int n,k;
	char s[100];
	
	scanf("%d %d", &n, &k );
	scanf("%s", &s);
	k--;
	if(s[k]=='A')	s[k]='a';
	if(s[k]=='B')	s[k]='b';
	if(s[k]=='C')	s[k]='c';
	
	printf("%s", s);
	
	return 0;
}

Measured memory_bytes: 128
def main():
    N=int(input())
    ac=0
    wa=0
    tle=0
    re=0
    for _ in range(N):
        i=input()
        if i=='AC': ac+=1
        elif i=='WA': wa+=1
        elif i=='TLE': tle+=1
        elif i=='RE': re+=1
    print(f'AC x {ac}')
    print(f'WA x {wa}')
    print(f'TLE x {tle}')
    print(f'RE x {re}')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9200
#include<stdio.h>
 
struct node{
    int key;
    struct node *next;
    struct node *prev;
};
 
typedef struct node * NodePointer;
NodePointer finditem(int);
void listprint(void);
NodePointer make_1node(int,NodePointer);
void deleteFirst(void);
void deleteLast(void);
void deleteNode(NodePointer);
NodePointer head;
 
int main(void){
    int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++;
      }
      size--;
    }
  }
    
  listprint();
  return 0;
}
 
NodePointer finditem(int key){
  NodePointer x;
  x = head->next;
  while(x != head && x->key != key){
    x = x->next;
  }
  return x;
}
 
void insert(int key){
  NodePointer y;
  y = malloc(sizeof(struct node));
  y->key = key;
  y->next = head->next;
  head->next->prev = y;
  head->next = y;
  y->prev = head;
    
}
 
void listprint(){
  NodePointer cur = head->next;
  int isf = 1;
  while(1){
    if ( cur == head ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}
  
void deleteFirst(){
  NodePointer t = head->next;
  if ( t == head ) return;
  deleteNode(t);
}
  
void deleteLast(){
  NodePointer t = head->prev;
  if ( t == head ) return;
  deleteNode(t);
}
  
void delete(int key){
  NodePointer k;
  k=finditem(key);
  if(k == head) return;
    
  deleteNode(k);
    
}
void init(){
  head = malloc(sizeof(struct node));
  head->next = head;
  head->prev = head;
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int main(){
      int m,n;
      while(scanf("%d",&m)&&m){
            scanf("%d",&n);
            int d[252];
            bool G[252][252];
            REP(i,n){
                  cin>>d[i+1];
                  d[i+1]=max(0,min(n+1,d[i+1]+i+1));
            }
            memset(G,false,sizeof(G));
            REP(i,n+1){
                  REP(j,m){
                        int now=min(n+1,i+j+1);
                        if(now>=n+1)G[i][n+1]=true;
                        else G[i][d[now]]=true;
                  }
            }
            //REP(i,n+2)REP(j,n+2)printf("%d%c",G[i][j]?1:0,j==n+1?'\n':' ');
            REP(k,n+2)REP(i,n+2)REP(j,n+2)if(G[i][k]&&G[k][j])G[i][j]=true;
            bool ans=true;
            REP(i,n+1){
                  if(G[0][i]&&!G[i][n+1])ans=false;
            }
            if(ans)cout<<"OK"<<endl;
            else cout<<"NG"<<endl;
      }
}

Measured memory_bytes: 1312
function main(input) {
  const x = parseInt(input.trim(), 10)

  let b = new Set([1])

  for (let j = 2; j <= 10; j++) {
    for (let i = 2; i ** j <= x; i++) {
      b.add(i ** j)
    }
  }

  console.log(Math.max(...b))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 30520
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <stack>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  stack<int> st;
  int n;
  while(cin >> n) {
    if (!n) {
      cout << st.top() << endl;
      st.pop();
    } else {
      st.push(n);
    }
  }
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, M;
  cin >> N >> M;
  deque< int > odd, even;
  for(int i = 0; i < M; i++) {
    int x;
    cin >> x;
    if(x & 1) odd.emplace_back(x);
    else even.emplace_back(x);
  }
  if(odd.size() >= 3) {
    cout << "Impossible" << endl;
  } else {
    if(odd.size()) {
      even.emplace_front(odd.back());
      odd.pop_back();
    }
    if(odd.size()) {
      even.emplace_back(odd.back());
      odd.pop_back();
    }
    for(auto t : even) cout << t << " ";
    cout << endl;

    if(even.size() == 1) {
      if(even[0] == 1) cout << 1 << endl << 1 << endl;
      else cout << 2 << endl << even[0] - 1 << " " << 1 << endl;
    } else {
      even.front()++;
      even.back()--;
      if(even.back() == 0) even.pop_back();
      cout << even.size() << endl;
      for(auto t : even) cout << t << " ";
      cout << endl;
    }
  }
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

int n;
string S, T;

template<class F>
bool canWin(int w, int src, F func) {
	Pii lost = {0, w-1};

	for (int i = n-1; i >= 0; i--) {
		if (func(T[i]) == -1) lost.y = min(lost.y+1, w-1);
		else if (func(T[i]) == 1) lost.x = max(lost.x-1, 0);

		if (func(S[i]) == -1) lost.x++;
		if (func(S[i]) == 1) lost.y--;
		if (lost.x > lost.y) return 0;
	}

	return src >= lost.x && src <= lost.y;
}

void run() {
	int h, w; cin >> h >> w >> n;
	int sr, sc; cin >> sr >> sc;
	cin >> S >> T;
	sr--; sc--;

	bool ans1 = canWin(w, sc, [&](char chr) {
		return (chr == 'L' ? -1 : (chr == 'R' ? 1 : 0));
	});

	bool ans2 = canWin(h, sr, [&](char chr) {
		return (chr == 'U' ? -1 : (chr == 'D' ? 1 : 0));
	});

	cout << (ans1 && ans2 ? "YES\n" : "NO\n");
}


Measured memory_bytes: 920
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	for (int i = 0;; i++){
		int N, ans = 0, cou = 0;
		cin >> N;
		if (N == 0)break;
		vint k(N);
		for (int j = 0; j < N; j++){
			cin >> k[i];
			if (k[i] == 0)ans--;
			if (k[i] == 1)cou++;
		}
		if (N + ans == cou)cout << "NA" << endl;
		else cout << N + 1+ans << endl;
	}
}




Measured memory_bytes: 3172
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
ans=0
while a:
    bb=b.pop()
    aa=a.pop()
    aa+=ans
    ans+=bb*((aa-1)//bb+1)-aa
print(ans)

Measured memory_bytes: 47448
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N, std::vector<std::string> S){
  set<string> x;
  for (int i = 0; i < N; i++) {
    x.insert(S[i]);
  }
  cout << x.size() << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
	std::vector<std::string> S(N);
	for(int i = 0 ; i < N ; i++){
		std::cin >> S[i];
	}
    solve(N, std::move(S));
}


Measured memory_bytes: 25148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,mod;
    cin>>n;
    mod=n%10;
    if(mod==3)
        cout<<"bon\n";
    else if(mod==0 || mod==1 || mod==6 || mod==8)
        cout<<"pon\n";
    else
        cout<<"hon\n";
    return 0;
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

int three(int x) {
	int ans = 1;
	rep(i, x) ans *= 3;
	return ans;
}

signed main() {
	int a, b, q, s[114514], t[114514];
	cin >> a >> b >> q;
	rep(i, a) cin >> s[i];
	rep(i, b) cin >> t[i];
	rep(i, q) {
		int x;
		cin >> x;
		int su, sd, tu, td;
		if (s[a - 1] < x) su = inf;
		else su = *(lower_bound(s, s + a, x));
		if (s[0] > x) sd = inf;
		else sd = *(upper_bound(s, s + a, x) - 1);
		if (t[b - 1] < x) tu = inf;
		else tu = *(lower_bound(t, t + b, x));
		if (t[0] > x) td = inf;
		else td = *(upper_bound(t, t + b, x) - 1);
		su = abs(su - x);
		sd = abs(sd - x);
		tu = abs(tu - x);
		td = abs(td - x);
		int mi = max(su, tu);
		mi = min(mi, max(sd, td));
		mi = min(mi, su + td + min(su, td));
		mi = min(mi, tu + sd + min(tu, sd));
		cout << mi << endl;
	}

	return 0;
}


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

ll ara[M];

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

    for(int i = 1; i <= n; i++) scanf("%lld", ara+i);

    ll x = 0;
    for(int i = 1; i <= n; i++) x ^= ara[i];

    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j < 60; j++)
        {
            if((x&(1LL<<j)) && (ara[i]&(1LL<<j))) ara[i] ^= (1LL<<j);
        }
    }

    int curr = 1;
    for(int j = 59; j >= 0; j--)
    {
        int paisi = -1;

        for(int i = curr; i <= n; i++)
        {
            if(ara[i]&(1LL<<j))
            {
                paisi = i;
                break;
            }
        }

        if(paisi == -1) continue;

        swap(ara[curr], ara[paisi]);

        for(int i = curr+1; i <= n; i++)
        {
            if(ara[i]&(1LL<<j)) ara[i] ^= ara[curr];
        }
        curr++;
    }

    //for(int i = 1; i <= n; i++) printf("--> %lld\n", ara[i]);

    ll ans = 0;
    curr = 1;

    for(int j = 59; j >= 0; j--)
    {
        if(ara[curr]&(1LL<<j))
        {
            if((ans&(1LL<<j)) == 0) ans ^= ara[curr];
            curr++;
        }
    }

    ans *= 2;
    ans += x;

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

    return 0;
}


Measured memory_bytes: 1024
MOD = 10**9
fact_inv, inv = [0]*10**6, [0]*10**6

def init_nCk():
    fact_inv[0] = fact_inv[1] = 1
    inv[1] = 1
    for i in range(2,10**6):
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        fact_inv[i] = fact_inv[i-1] * inv[i] % MOD

def nCk(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    ans = 1
    for i in range(n, n-k+1 - 1, -1):
        ans *= i
        ans %= MOD
    return ans * fact_inv[k] % MOD
init_nCk()

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)

ans = 0
for i in B.values():
    ans += i*(i-1)//2

for a in A:
    k = B[a]
    print(ans - nCk(k-1,1))

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


int main(void)
{
    long long A,B;
    double fb;

    cin >> A >> fb;

    B = fb * 1000;
    if (B % 10 > 5) B += 10;
    B /= 10;

    long long ans;
    ans = A * B / 100;
    cout << ans << endl;
}


Measured memory_bytes: 3708