akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

char toChar(int a)
{
	char c = a + 48;
	return c;
}
bool notFinish = true;

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

	int n, k;
	cin >> n >> k;

	if (n == k || k==1)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << n - k << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef int LL;
const LL maxn=5e3+9;
const LL dx[]={0,0,1,0,-1},dy[]={0,1,0,-1,0};
struct node{
	LL x,y;
}a[maxn*maxn];
LL ret,n;
LL mark[maxn][maxn],ans[maxn][maxn];
LL Check(LL x,LL y){
	return x>=1 && x<=n && y>=1 && y<=n;
}
std::queue<node> que;
void Bfs(LL x,LL y){
	que.push((node){x,y});
	while(!que.empty()){
		node Tmp(que.front()); que.pop();
		x=Tmp.x; y=Tmp.y;
		for(LL i=1;i<=4;++i){
			LL xx(x+dx[i]),yy(y+dy[i]);
			if(Check(xx,yy) && ans[xx][yy]>ans[x][y]+mark[x][y]){
				/*if(xx==2 && yy==2){
					printf("# (%d,%d,%d)%d,%d,%d,%d,%d(%d,%d)\n",i,dx[i],dy[i],x,y,ans[x][y],mark[x][y],ans[xx][yy],xx,yy);
				}*/
				ans[xx][yy]=ans[x][y]+mark[x][y];
				que.push((node){xx,yy});
			}
		}
	}
}
void Out(){
	for(LL i=1;i<=n;++i){
		for(LL j=1;j<=n;++j) printf("%d ",ans[i][j]); puts("");
	}
}
int main(){
	scanf("%d",&n);
	for(LL i=1;i<=n*n;++i){
		LL x; scanf("%d",&x);
		a[i].x=(x-1)/n+1; a[i].y=x%n;
		if(!a[i].y) a[i].y=n;
	}
	/*for(LL i=1;i<=n*n;++i){
		printf("(%d,%d)\n",a[i].x,a[i].y);
	}*/
	//return 0;
	for(LL i=1;i<=n;++i){
		for(LL j=1;j<=n;++j){
			mark[i][j]=1;
		}
	}
	for(LL i=1;i<=n;++i){
		for(LL j=1;j<=n;++j){
			ans[i][j]=std::min(std::min(i-1,n-i),std::min(j-1,n-j));
		}
	}
	//printf("%d\n",ans[2][2]);
	for(LL i=1;i<=n*n;++i){
		LL x(a[i].x),y(a[i].y);
		ret+=ans[x][y]; mark[x][y]=0;
		Bfs(x,y);
		//Out();
		//if(i==3) return 0;
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 11656
strings = list(input())


num = 0
while True:
    if len(strings) <= 2:
        break
    flag = False
    for i, _ in enumerate(strings):
        last = len(strings) - 1
        if i == 0 or i == last:
            continue
        if strings[i-1] != strings[i+1]:
            strings.pop(i)
            num += 1
            flag = True
        else:
            continue
    if not flag:
        break

if not num % 2:
    print('Second')
else:
    print('First')


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define IOS                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
#define int long long
const unsigned int M = 1000000007;
using namespace std;
int32_t main()
{
  IOS int t=1;
 // cin >> t;
  while (t--)
  {
      int a;
      cin>>a;
      cout<<a*a+a+a*a*a<<endl;
  }

  return 0;
}


Measured memory_bytes: 3688
list =[]
while True:
    m,r,f = map(int,input().split())
    if m == -1 and r == -1 and f == -1:
        break

    elif m == -1 or r == -1:
        list.append("F")

    elif m+r >= 80:
        list.append("A")

    elif 65 <= m+r < 80:
        list.append("B")

    elif 50 <= m+r < 65:
            list.append("C")

    elif 30 <= m+r < 50:
        if f >= 50:
            list.append("C")
        else:
            list.append("D")

    elif  m+r < 30:
            list.append("F")

[print(i) for i in list]


Measured memory_bytes: 5600
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll N, D;
    in(N);
    in(D);

    int count = 0;

    rep(i, N)
    {
        ll X, Y;
        in2(X, Y);

        if (X * X + Y * Y <= D * D) count++;
    }

    outl(count);

    return 0;
}

Measured memory_bytes: 3684
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
K,N = LI()
A = LI()
A = A + [A[0]+K]
ans = 0
for i in range(N):
    ans = max(ans,A[i+1]-A[i])
print (K - ans)


Measured memory_bytes: 99016
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//#pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

using namespace std;

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)(x).size()

typedef  long long ll;

const int maxn = (int)2e6 + 13;
const ll INFL = 9223372036854775807;
const ll INF = 2147483647;
const ll MOD = (int)1e9 + 7, MOD2 = 998244353;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;

int a[maxn];
int mp[maxn];
int main() {
	drobucs;
	
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)cin >> a[i], mp[a[i]]++;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		bool f = 1;
		for (ll j = 2; j * j <= a[i]; ++j) {
			if (a[i] % j == 0 && (mp[j] != 0 || mp[a[i] / j] != 0))
				f = 0;
		}
		if (a[i] != 1 && mp[1] != 0)f = 0;
		if (mp[a[i]] > 1)f = 0;
		ans += f;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8228
import scala.collection.mutable.Stack
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  val bst = new Bst()
  val n = readInt
  for (_ <- 0 until n) {
    val arr = readLine.split(" ")
    val cmd = arr(0)
    cmd match {
      case "insert" => bst.insert(arr(1).toInt)
      case "print" => bst.printTree()
    }
  }

  class Node(val value: Int) {
    var left: Node = null
    var right: Node = null
    var visited: Boolean = false
  }

  class Bst {
    var size = 0
    var root: Node = null
    def insert(value: Int): Unit = {
      size += 1
      if (root == null) {
        root = new Node(value)
        return
      }
      var prev: Node = null
      var cur = root
      while (cur != null) {
        prev = cur
        if (cur.value > value) {
          cur = cur.left
          if (cur == null) prev.left = new Node(value)
        } else {
          cur = cur.right
          if (cur == null) prev.right = new Node(value)
        }
      }
    }

    def printTree(): Unit = {
      printInOrder()
      printPreOrder()
    }

    def printInOrder(): Unit = {
      val stack = new Stack[Node]
      stack.push(root)
      while (!stack.isEmpty) {
        var node = stack.top
        while (node.left != null && !node.left.visited) {
          stack.push(node.left)
          node = node.left
        }
        node = stack.pop
        if (!node.visited) {
          print(s" ${node.value}")
          node.visited =true
        }
        if (node.right != null && !node.right.visited) {
          stack.push(node.right)
        }
      }
      println()
    }

    def printPreOrder(): Unit = {
      val stack = new Stack[Node]
      stack.push(root)
      while (!stack.isEmpty) {
        val node = stack.pop
        if (node != null) {
          print(s" ${node.value}")
          node.visited = false
          stack.push(node.right)
          stack.push(node.left)
        }
      }
      println()
    }

  }
}



Measured memory_bytes: 460504
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	ll n;
	cin>>n;
	std::vector<ll> a(n);
	ll cp=0,cn=0;
	rep(i,0,n)
	{
		cin>>a[i];
		if(a[i]>=0)
			cp++;
		else
			cn++;
	}
	std::vector<pii> res;
	if(cp==n)
	{
		sort(all(a));
		ll curr=a[0];
		rep(i,1,n)
		{
			if(i!=(n-1))
			{
				res.pb({curr,a[i]});
				curr=(curr-a[i]);
			}
			else
			{
				res.pb({a[i],curr});
				curr=(a[i]-curr);
			}
		}
		cout<<curr<<endl;
		for(auto i:res)
		{
			cout<<i.F<<" "<<i.S<<endl;
		}	
		exit(0);
	}
	if(cn==n)
	{
		sort(all(a));
		reverse(all(a));
		ll curr=a[0];
		rep(i,1,n)
		{
			
				res.pb({curr,a[i]});
				curr=(curr-a[i]);
			
		}
		cout<<curr<<endl;
		for(auto i:res)
		{
			cout<<i.F<<" "<<i.S<<endl;
		}	
		exit(0);
	}
		sort(all(a));
		ll stp=0;
		rep(i,0,n)
		{
			if(a[i]>=0)
			{
				stp=i;
				break;
			}
		}		
		ll curr=a[0];
		rep(i,stp,n)
		{
			if(i!=(n-1))
				{
					res.pb({curr,a[i]});
					curr=(curr-a[i]);
				}
				else
				{
					res.pb({a[i],curr});
					curr=(-curr+a[i]);	
				}
			
		}
		rep(i,1,stp)
		{
			res.pb({curr,a[i]});
			curr=(curr-a[i]);
		}
		cout<<curr<<endl;
		for(auto i:res)
		{
			cout<<i.F<<" "<<i.S<<endl;
		}	
		exit(0);

	
	
}

Measured memory_bytes: 4336
/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃ 　
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting　　　　　　　　　　
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃　　　　　　　　　　　
 * 　　　　　　　　　┃          ┃  　　　　　　
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃　　　　　　　　　　　
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */ 
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define inf 1000000000
#define maxn 100000+5
#define maxm 100005
#define eps 1e-10
#define for0(i,maxn) for(int i=1;i<=(maxn);++i)
#define for1(i,maxn) for(int i=1;i<=(maxn);++i)
#define for2(i,x,y) for(int i=(x);i<=(y);++i)
#define for3(i,x,y) for(int i=(x);i>=(y);--i)
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
struct len{
    int x,y;
}pp[maxn];
int cmp(len x1,len x2)
{
    return x1.y<x2.y;
}
int main()
{
	int n,m;
    n=read();m=read();
    for(int i=1;i<=m;++i) pp[i].x=read(),pp[i].y=read();
    sort(pp+1,pp+m+1,cmp);
    int l=0,ans=0;
    for(int i=1;i<=m;++i)
    {
        if(pp[i].x>=l) {
            l=pp[i].y;
            ans++;
        }
    }
    cout<<ans<<endl;
 } 


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

#define MAX(a , b) (a > b? a : b)
#define MIN(a , b) (a < b? a : b)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

const double pi = 2.0*acos(0.0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    string s;
    cin >> s;
    if (s[2]==s[3] && s[4]==s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char n[4] ;
    int i, f = 0;
    scanf("%s", n);
    for (i = 0; i < 3; i++)
    {
        if (n[i] == '7')
            f = 1;
    }
    if (f == 1) printf("Yes");
    else printf("No");
    return (0);
}

Measured memory_bytes: 1728
#include<iostream>
#include<string>
#include<stdlib.h>
#include<map>

using namespace std;

class data
{
public:
	int times;
	bool flag[2];
	int n;
	data()
	{
		times=0;
		flag[0]=false;
		flag[1]=false;
	}
};

int main(void)
{
	map<int,data> d;
	int month=0;
	while(1)
	{
		string s;
		getline(cin,s);
		if(cin.eof())break;
		if(s.length()==0)month++;
		for(int i=0;i<s.length();i++)
		{
			if(s[i]==',')
			{
				int n=atoi(s.substr(0,i).c_str());
				d[n].flag[month]=true;
				d[n].times++;
				d[n].n=n;
			}
		}
	}
	for(map<int,data>::iterator it=d.begin();it!=d.end();it++)
	{
		if((*it).second.flag[0]&&(*it).second.flag[1])
		{
			cout<<(*it).second.n<<' '<<(*it).second.times<<endl;
		}
	}
}

Measured memory_bytes: 1192
# -*- coding: utf-8 -*-

N = int(input())

C_list = [0] * (N-1)
S_list = [0] * (N-1)
F_list = [0] * (N-1)
for i in range(N-1):
    C_list[i], S_list[i], F_list[i] = map(int, input().split())

# 出発駅の数でループ
for i in range(N-1):
    # 次の行の出力のために初期化
    ans = 0
    # ある出発駅から最終駅までのループ
    for j in range(i, N-1):
        # 開始時の待ち時間
        if ans < S_list[j]:
            ans = S_list[j]
        # 次の駅への移動時間
        ans += C_list[j]
        # 次の出発前の待ち時間(最終駅に着いた時以外)
        if j != N-2:
            if ans % F_list[j+1] != 0:
                ans += F_list[j+1] - ans % F_list[j+1]
    print(ans)
# 出発駅 = 最終駅の出力
print(0)

Measured memory_bytes: 3064
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d",&n,&m);
	m=m*2;
	if(n-m<0)cev=0;
	else cev=n-m;
	printf("%d\n",cev);
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<stdlib.h>

using namespace std;

int main(){
  int N;
  int h[111111];
  int i;
  cin >> N;
  for(i=0;i<=N-1;i++)
    cin >> h[i];
  int dp[111111];
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  for(i=2;i<=N-1;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] << endl;
  
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int i,j;

	int n,m;
	int a[100][100];
	int b[100];
	int c[100];

	scanf("%d %d",&n,&m);

	for(i = 0; i < n; i++)
	{
		for(j = 0; j < m; j ++)
		{
			scanf("%d", &a[i][j]);
		}
	}

	for(j = 0; j < m; j++)
	{
		scanf("%d", &b[j]);
	}

	for(i = 0; i < n; i++)
	{
		c[i] = 0;
		for(j = 0; j < m; j++)
		{
			c[i] += a[i][j] * b[j];
		}
		printf("%d\n", c[i]);
	}


	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int gcd(long int a, long int b){
    long int min_ = min(a, b);
    long int max_ = max(a, b);
    if (min_ == 0)
    {
        return max_;
    }
    else
    {
        return gcd(min_, max_ % min_);
    }
}

int main(void){
    long int A, B, C, D;
    cin >> A >> B >> C >> D;
    long int lcm;
    lcm = C / gcd(C, D) * D;
    long int c, d, cd;
    c = B / C - (A-1) / C;
    d = B / D - (A-1) / D;
    cd = B / lcm - (A-1) / lcm;
    cout << B - A - c - d + cd + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
  long int N, K, num;
  int flag = 0;
  
  scanf("%ld %ld", &N, &K);
  
  num = N % K;
  
  if(num < K - num)
    printf("%ld\n", num);
  
  else
    printf("%ld\n", K - num);
  
  return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
#define maxn 100005
#define maxm 500005
#define inf 0x7fffffff
#define ll long long
#define ld long double
#define debug(x) cerr<<#x<<": "<<x<<endl
#define fgx cerr<<"--------------"<<endl
#define dgx cerr<<"=============="<<endl

using namespace std;
struct vc{
	ld x,y;
	vc operator*(const ld b){vc t;t.x=x*b,t.y=y*b;return t;}
};
struct pt{
	ld x,y;
	pt operator+(const vc b){pt t;t.x=x+b.x,t.y=y+b.y;return t;}
	vc operator-(const pt b){vc t;t.x=x-b.x,t.y=y-b.y;return t;}
};

inline int read(){
	int x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}

inline pt get(){pt t;t.x=read(),t.y=read();return t;}
inline ld cross(vc a,vc b){return a.x*b.y-a.y*b.x;}
inline ld dot(vc a,vc b){return a.x*b.x+a.y*b.y;}
inline ld len(vc a){return dot(a,a);}

int main(){
	pt p0=get(),p1=get();
	int Q=read();
	while(Q--){
		pt p2=get(); 
		vc a=p1-p0,b=p2-p0;
		ld cj=cross(a,b);
		if(cj!=0){
			if(cj>0) printf("COUNTER_CLOCKWISE\n");
			else printf("CLOCKWISE\n");
		}
		else{
			if(dot(a,b)<0) printf("ONLINE_BACK\n");
			else{
				if(len(a)<len(b)) printf("ONLINE_FRONT\n");
				else printf("ON_SEGMENT\n");
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3068
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;

//----------------------------------------------------------------
signed main(){

	ll n,k;
	string s;
	cin >> n >> k >> s;

	ll ans = 0;
	int now = 1;
	while(k > 0 && now < n){	
		while(now < n && s[now] == s[now-1]){
			now++;
		}
		while(now < n &&s[now] != s[now-1]){
			if(s[now]=='L')s[now]='R';
			else s[now]='L';
			now++;
		}
		k--;
	}
	rep(i,n-1)if(s[i]==s[i+1])ans++;
	cout << ans << endl;


	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc140.contest.atcoder.jp/tasks/abc140_a

Measured memory_bytes: 512
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    vector<int> m(5);
    int max_m = 0; 
    rep(i, 5){
        cin >> m[i];
        chmax(max_m, (10 - m[i] % 10) % 10);
        m[i] = (m[i] + 9) / 10 * 10;
    }
    cout << accumulate(all(m), 0) - max_m << endl;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
ans = 10**7
if x >= y :
    if a+b > 2*c:
        ans =2*y*c + (x-y)*min(a,2*c)
       
    else:
        ans = x*a+y*b
else:
    if a+b>2*c:
        ans = 2*x*c+(y-x)*min(b,2*c)
    else:
        ans = x*a+y*b
print(ans)

Measured memory_bytes: 3064
#https://atcoder.jp/contests/abc131/tasks/abc131_b

n,l = [int(i) for i in input().split()]

a = list(range(l,l+n))
b = []
for i in range(len(a)):
    b.append(abs(a[i]))
c = b.index(min(b))

print(sum(a) - a[c])

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

#define int long long
typedef pair <int, int> pii;

const int N = 3e5 + 10;
int x, y, z, dpl[N], dpr[N];
multiset <pii> st;

struct ms {
	int a, b, c;
	
	ms() {
		a = b = c = 0;
	}
	
	ms(int x, int y, int z) {
		a = x;
		b = y;
		c = z;
	}
} ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> y >> z;
	for (int i = 0; i < x + y + z; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		ar[i] = ms(a, b, c);
	}
	sort(ar, ar + x + y + z, [&] (ms a, ms b) { return a.b + b.c > a.c + b.b; });
	
	int ansx = 0, ansy = 0;
	pii last;
	for (int i = 0; i < y; i++) {
		st.insert({ar[i].a - ar[i].b, ar[i].b});
		ansy += ar[i].b;
	}
	last = *st.rbegin();
	dpl[y - 1] = ansy;
	
	for (int i = y; i < x + y; i++) {
		int tmp = ar[i].a - ar[i].b, ty = ar[i].b;
		if (tmp >= last.first) {
			st.insert({tmp, ty});
			ansx += ar[i].a;
		}
		else {
			st.insert({tmp, ty});
			auto it = st.lower_bound(last);
			assert(it != st.begin());
			it--;
			ansy += ty;
			ansy -= last.second;
			ansx += last.second + last.first;
			last = *it;
		}
		dpl[i] = ansx + ansy;
	}
	
	
	int ansz = 0;
	ansx = 0;
	st.clear();
	for (int i = x + y + z - 1; i >= x + y; i--) {
		st.insert({ar[i].a - ar[i].c, ar[i].c});
		ansz += ar[i].c;
	}
	last = *st.rbegin();
	dpr[x + y] = ansz;
	
	for (int i = x + y - 1; i >= y; i--) {
		int tmp = ar[i].a - ar[i].c, tz = ar[i].c;
		if (tmp >= last.first) {
			st.insert({tmp, tz});
			ansx += ar[i].a;
		}
		else {
			st.insert({tmp, tz});
			auto it = st.lower_bound(last);
			assert(it != st.begin());
			it--;
			ansz += tz;
			ansz -= last.second;
			ansx += last.second + last.first;
			last = *it;
		}
		dpr[i] = ansx + ansz;
	}
	
	
	int ans = 0;
	for (int i = y - 1; i < x + y; i++)
		ans = max(ans, dpl[i] + dpr[i + 1]);
	cout << ans;
}

Measured memory_bytes: 16768
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, p = map(int, input().split())

from collections import Counter;
def prime_factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

soinsu = prime_factorize(p)

ans =1
for k,v in soinsu.items():
    if v>=n:
        ans *= k**(v//n)

print(ans)


Measured memory_bytes: 3316
/**
 *     author: qodjf
 *     created: 04.30.2020 20:32:33
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

ll mul(ll a, ll b) { return a * b % MOD; }

ll add(ll a, ll b) { return (a + b) % MOD; }

ll sub(ll a, ll b) { return (a - b + MOD) % MOD; }

ll my_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}

ll my_inv(ll a) { return my_pow(a, MOD - 2); }

namespace Comb {
const int MAXK = 2e5 + 5;
int fac[MAXK], inv_fac[MAXK];

void init() {
  fac[0] = inv_fac[0] = 1;
  for (int i = 1; i < MAXK; ++i) {
    fac[i] = mul(fac[i - 1], i);
    inv_fac[i] = my_inv(fac[i]);
  }
}

int C(int a, int b) {
  if (a < 0 || b < 0 || b > a) {
    return 0;
  }
  return mul(fac[a], mul(inv_fac[b], inv_fac[a - b]));
}

}  // namespace Comb

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

  int N;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  Comb::init();
  vector<int> tmp(N - 1);
  tmp[0] = 1;
  for (int i = 1; i < N - 1; i++) {
    tmp[i] = add(mul(i + 1, tmp[i - 1]), Comb::fac[i]);
  }

  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans = add(ans, mul(x[i + 1] - x[i],
                       mul(tmp[i], mul(Comb::fac[N - 1], Comb::inv_fac[i + 1]))));
  }
  cout << ans << endl;
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var acro = "" + ss[0][0] + ss[1][0] + ss[2][0];
            Console.WriteLine(acro.ToUpper());
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long int
#define ld long double

using namespace std;


int main()

{

ios_base::sync_with_stdio(false);
cin.tie(NULL);




   {

     ll a,b,c;
     cin>>a>>b>>c;
     a=abs(a);
     b=abs(b);
     c=abs(c);

     ll g=(a*b*c);
     ll ma=max(a,b);
     ma=max(ma,c);
     g/=ma;
     g/=2;

     cout<<g<<endl;


   }


return 0;

}


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

using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    ll cnt = 0;
    for (char c : s) {
        cnt += atoi(&c);
    }
    if (cnt % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3748
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = map(int, raw_input().split())

if x in a:
    if y in a:
        print 'Yes'
    else:
        print 'No'
elif x in b:
    if y in b:
        print 'Yes'
    else:
        print 'No'
else:
    if y in c:
        print 'Yes'
    else:
        print 'No'

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>

#define MIN(a, b) ((a) <= (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define for_p(i, a, b) for(int i = a; i < b; i++)
#define for_m(i, a, b) for(int i = a - 1; i >= b; i--)

//a = s1.size();
//vector<string> s1;
//string s2 = accumulate( s1.begin(), s1.end(), string() );

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0;
  int i = 0, j = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  char s1[200000], s2[200000], s3[200000];
  
  cin >> a;
  
  for(i = 0; i < a - 1; i++){
    cin >> a1[i];
  }
  for(i = 0; i < a; i++){
      if(i == 0){
        a2[i] = a1[i];
        b += a2[i];
      }else if(i == a - 1){
        a2[i] = a1[i - 1];
        b += a2[i];
      }else{
        a2[i] = MIN(a1[i - 1], a1[i]);
        b += a2[i];
      }   
  }
  cout << b << endl;
}
  




Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int A, B, C;

    scanf("%d %d %d", &A, &B, &C);
    if((A==C && B!=C) || (B==C && A!=B) || (A==B && A!=C)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}

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

AB = []
for n in range(N):
    AB.append(list(map(int,input().split())))

aaa = sorted(AB, key=lambda x:(x[1], x[0]))

sumW = 0
for a in aaa:
    sumW += a[0]
    if sumW > a[1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 91664
import math
a, b, x = map(int, input().split())

x /= a

if x/a == b/2:
    print(math.degrees(math.atan2(b, a)))
elif x/a < b/2:
    print(math.degrees(math.atan2(b, 2*x/b)))
else:
    print(math.degrees(math.atan2(2*(b-x/a), a)))


Measured memory_bytes: 3188
a = [list(map(int, input().split())) for l in range(3)]
n = int(input()) 
b = [int(input()) for i in range(n)] 

for x in range(n):
	for i in range(3):
		for j in range(3):
			if a[i][j] == b[x]:
				a[i][j] = 0
                
for r in range(3):
	if a[r]==[0, 0, 0]:
		print('Yes')
		exit()
	if a[0][r]==a[1][r]==a[2][r]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int cur = 0, m = 0;
	cin >> s;
	for (int i = 0; i < s.size(); ++i){
		if (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T'){
			cur = 0;
		}
		else cur++;
		m = max(m,cur);
	}  
	cout << m << '\n';
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

vector<int> a,ans;
const int N=2e5+5;
vector<int> G[N];
void dfs(int u,int fa,vector<int>& lis){
    int flag;
    int pos=lower_bound(all(lis),a[u])-lis.begin();
    if(pos==lis.size()) lis.push_back(a[u]),flag=-1;
    else flag=lis[pos],lis[pos]=a[u];
    ans[u]=lis.size();
    for(auto it:G[u]){
        if(it==fa) continue;
        dfs(it,u,lis);
    }
    if(flag==-1) lis.pop_back();
    else lis[pos]=flag;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    a=ans=vector<int>(n+1);
    for1(i,n) cin>>a[i];
    forn(i,n-1){
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    vector<int> v{};
    dfs(1,-1,v);
    for1(i,n) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 30068
import math

def main():
    counter: int = 0
    n, d = map(int, input().split())
    x = [0] * n
    y = [0] * n

    for i in range(n):
        x[i], y[i] = map(int, input().split())

    for i in range(n):
        distance: int = math.sqrt(x[i] ** 2 + y[i] ** 2)
        if distance <= d:
            counter += 1

    print(counter)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24692
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    string s;
    cin >> s;
    rep(i, 3){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
a = list(map(int, input().split()))

ans = []
over = 0
for i in range(N):
  n = a[i] // 400
  if n < 8:
    if n not in ans:
      ans.append(n)
  else:
    over += 1
    
cnt = len(ans) + over
if len(ans) > 0:
  print(len(ans), cnt)
else:
  print(1, cnt)

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

int main(void)
{
    int a, b, c, d;
    int t_win, a_win;
    cin >> a >> b >> c >> d;
    t_win = 0;
    a_win = 0;
    for (;;)
    {
        c = c - b;
        if (c <= 0)
        {
            t_win = 1;
            break;
        }
        a = a - d;
        if (a <= 0)
        {
            a_win = 1;
            break;
        }
    }
    if (t_win == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

typedef long long ll;
const int mod = 1e9 + 7;

ll N, K, S;

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

    rep(i, K) {
        printf("%lld ", S);
    }

    rep(i, N - K) {
        ll other = S - 1;
        if (S == 1 || S == 2) {
            other = 3;
        }
        printf("%lld ", other);
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define endl ("\n")
#define deb(x) cout << (#x) << " = " << (x) << endl;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    
    int n, x;
    cin >> n >> x;
    int arr[n];
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i];
    }
    int brr[n+1];
    brr[0] = 0;
    for(int i = 1;i<=n;i++)
    {
        brr[i] = brr[i-1] + arr[i-1];
    }
    int count = 0;
    for(int i = 0;i <= n;i++)
    {
        if(brr[i] <= x)
            count++;
    }
    cout << count;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    int n,d,x,y;
    cin>>n>>d;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        double f=sqrt(pow(x,2)+pow(y,2));
        if(f<=1.0*d)
            sum++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
  
int main () {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  int B = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (i > 0 && i < N) {
      B = max(B, A.at(i) - A.at(i - 1));  
    }
    if (i == N - 1) {
      B = max(B, K - A.at(i) + A.at(0));
    }
  }
  int ans = K - B;
  cout << ans << endl;
}

Measured memory_bytes: 4048
using System;
     
    namespace abc079_a
    {
        class Program
        {
            static void Main(string[] args)
            {
                string s = Console.ReadLine();
                Console.WriteLine((s[0] == s[1] || s[2] == s[3]) && s[1] == s[2] ? "Yes" : "No");
            }
        }
    }

Measured memory_bytes: 11092
n, A, B, k = list(map(int, input().split()))

MOD = 998244353
MAX = 3*10**5+2

fac = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
ifac = [0 for i in range(MAX)]
fac[0] = 1; fac[1] = 1
inv[1] = 1
ifac[0] = 1; ifac[1] = 1

for i in range(2, MAX):
  fac[i] = fac[i-1]*i%MOD
  inv[i] = inv[MOD%i]*(MOD-MOD//i)%MOD
  ifac[i] = ifac[i-1]*inv[i]%MOD

def nCk(n, k):
  if n<k or n<0 or k<0: return 0
  return (((fac[n]*ifac[k])%MOD)*ifac[n-k])%MOD

ans = 0
for i in range(n+1):
  if (k-A*i)%B == 0:
    b = (k-A*i)//B
    if 0<=b<=n:
      ans = (ans+nCk(n, i)*nCk(n, b))%MOD

if ans==0:
  print(1)
else:
  print(ans)

Measured memory_bytes: 67344
#include<iostream>
#include<vector>
#include<set>
using namespace std;

int main(){
    int n; cin>>n;
    set<int> s;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(s.find(a)==s.end()) s.insert(a);
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

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

int main(){
  int n, x = 0, max = 0;
  string s;
  cin >> n;
  cin >> s;
  for(int i=0;i<n;i++){
    if(s[i]=='I'){
      x++;
      if(max<x)max = x;
    }
    else if(s[i]=='D')x--;
  }
  cout << max << endl;
  return 0;
}


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

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> vec(100);
  for (int i = 0; i < m * 2; i++) {
    std::cin >> vec.at(i);
  }
  for (int i = 0; i < n; i++) {
    size_t n_count = std::count(vec.begin(), vec.end(), i+1);
    std::cout << n_count << std::endl;
  }
}

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

public class Main {

	/**
	 * AOJ 0005 GCD and LCM
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in));

		String input = bufferedReader.readLine();
		String[] twoStr;
		while (input != null) {
			twoStr = input.split("\\s");
			int[] twoInt = getintArray(twoStr);
			int gcd = getGCD(twoInt);
			int lcm = getLCM(twoInt, gcd);
			System.out.println(gcd + " " + lcm);
			input = bufferedReader.readLine();
		}
	}

	/**
	 * String????????????int?????????????????????????????????????????????????????´??????
	 *
	 * @param strArray
	 *            String?????????
	 * @return int?????????
	 */
	private static int[] getintArray(String[] strArray) {
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		Arrays.sort(intArray);
		return intArray;
	}

	private static int getGCD(int[] twoIntOrg) {
		int tmp, diff;
		int[] twoInt = { twoIntOrg[0], twoIntOrg[1] };
		while (twoInt[0] != twoInt[1]) {
			diff = twoInt[1] - twoInt[0];
			if (diff > twoInt[0]) {
				twoInt[1] = diff;
			} else {
				tmp = twoInt[0];
				twoInt[0] = diff;
				twoInt[1] = tmp;
			}
		}
		return twoInt[0];
	}

	private static int getLCM(int[] twoInt, int gcd) {
		return twoInt[0] / gcd * twoInt[1];
	}
}

Measured memory_bytes: 16932
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer line1 = new StringTokenizer(bf.readLine());
 		int sum1 = 0;
 		int sum2 = 0;
 		int[] array1 = new int[n];
 		for(int i = 0;i<n;i++){
 			array1[i] = Integer.parseInt(line1.nextToken());
 		}
 		for(int i = 0;i<n;i++){
 			sum1+=(array1[i]-1)*factorial(n-1-i);
 			for(int j = i+1;j<n;j++){
 				if (array1[j] > array1[i])
 					array1[j]--;
 			}
 		}
 		
 		StringTokenizer line2 = new StringTokenizer(bf.readLine());
 		int[] array2 = new int[n];
 		for(int i = 0;i<n;i++){
 			array2[i] = Integer.parseInt(line2.nextToken());
 		}
 		for(int i = 0;i<n;i++){
 			sum2+=(array2[i]-1)*factorial(n-1-i);
 			for(int j = i+1;j<n;j++){
 				if (array2[j] > array2[i])
 					array2[j]--;
 			}
 		}
 		out.println(Math.abs(sum1-sum2));
 		out.close();
 		
 		
 		
 		
 		
 	}
	public static int factorial(int n){
		int prod =1;
		while(n > 0){
			prod*=n;
			n--;
		}
		return prod;
	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25392
n=int(input())
dp=[[0]*3 for i  in range(n+1)]
for i in range(n):
  a,b,c=map(int,input().split())
  dp[i+1][0]=max(dp[i][1],dp[i][2])+a
  dp[i+1][1]=max(dp[i][0],dp[i][2])+b
  dp[i+1][2]=max(dp[i][0],dp[i][1])+c
print(max(dp[-1]))

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

typedef pair<int, int> ii;

vector<int> edg[100010];

int dp[100010];


int dfs(int node){
    if(dp[node]){
        return dp[node];
    }

    if(edg[node].empty()){
        dp[node] = 1;
    }else{
        for(auto x : edg[node]){
            dp[node] = max(dp[node], dfs(x) + 1);
        }
    }
    return dp[node];
}

int main(){
    int n, m;
    cin >> n >> m;
    int a, b;
    memset(dp, 0, sizeof(dp));

    for(int i = 0 ; i < m ; i++){
        cin >> a >> b;
        edg[a].push_back(b);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, dfs(i));
    }


    cout << ans-1 << endl;

    return 0;
}




Measured memory_bytes: 7424
fun main(args: Array<String>) {
    edpe()
}

private data class ItemE(val weight: Int, val value: Int)

fun edpe() {
    val (numberOfItems, weightLimit) = readLine()!!.split(" ").map { it.toInt() }
    val items = (1..numberOfItems).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { ItemE(it[0], it[1]) }

    val maxN = 101
    val maxValue = numberOfItems * 1000

    // dp[品物の数][価値の総和] = 価値の総和以上になるよう品物をi個選んだときの重量の最小値
    val dp = Array(maxN + 1) { LongArray(maxValue + 1) { Long.MAX_VALUE / 2 } }

    dp[0][0] = 0

    for (i in 0 until numberOfItems) {
        for (sumValue in 0..maxValue) {
            val item = items[i]

            if (sumValue - item.value >= 0) {
                dp[i + 1][sumValue] = Math.min(
                    dp[i + 1][sumValue],
                    dp[i][sumValue - item.value] + item.weight
                )
            }
            dp[i + 1][sumValue] = Math.min(dp[i + 1][sumValue], dp[i][sumValue])
        }
    }

    val answer = dp[numberOfItems].indexOfLast { it <= weightLimit }

    println(answer)
}


Measured memory_bytes: 153584
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 int main() {
	 string X, Y;
	 cin >> X >> Y;
	 if (X[0] < Y[0]) cout << "<" << endl;
	 else if (X[0] == Y[0]) cout << "=" << endl;
	 else cout << ">" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	double w,h,x,y;
	scanf("%lf%lf%lf%lf",&w,&h,&x,&y);
	printf("%lf ",w*h/2);
	if(x==w/2 && y==h/2)
		printf("1");
	else
		printf("0");
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Tue Aug  7 23:57:38 2018

@author: Yuki
"""

s = input()
K = int(input())

string_cands = []
s_length = len(s)
for i in range(s_length):
    for ii in range(1, K+1):
        string_cands.append(s[i:i+ii])
print(sorted(set(string_cands))[K-1])



Measured memory_bytes: 5068
#include <stdio.h>
#include <string.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, ans = 0;
  char s[1200];
  scanf("%s", s);
  scanf("%lld", &n);
  for(i = 0; i < strlen(s); i += n) printf("%c", s[i]);
  return 0;
}

Measured memory_bytes: 128
/**
 *    author:  tourist
 *    created: 23.09.2017 15:03:08       
**/
#include <bits/stdc++.h>

using namespace std;

void err() {
  puts("No");
  exit(0);
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<int> cnt(26, 0);
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for (char c : s) {
      cnt[c - 'a']++;
    }
  }
  if ((h * w) % 2 == 1) {
    for (int i = 0; i < 26; i++) {
      if (cnt[i] % 2 == 1) {
        cnt[i]--;
        break;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    if (cnt[i] % 2 == 1) {
      err();
    }
  }
  int k2 = 0;
  if (h % 2 == 1) {
    k2 += w / 2;
  }
  if (w % 2 == 1) {
    k2 += h / 2;
  }
  int have2 = 0;
  for (int i = 0; i < 26; i++) {
    have2 += (cnt[i] % 4 == 2);
  }
  if (have2 > k2) {
    err();
  }
  puts("Yes");
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > c) {
    cout << "NO" << endl;
  }
  else if (a + b >= c) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
long long p = 1000000007;
long long n, k, x, ans;
int main() {
	scanf("%lld%lld", &n, &k);
	for (long long i = k; i <= n + 1; i++) {
		x = (2 * n - i + 1) * i - (i - 1) * i;
		x /= 2;
		ans += x + 1;
		ans %= p;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1728
a , b, c = map(int,input().split())
aaa = [a,b,c]
m = max(a,b,c)
aaaa = list(sorted(aaa))
x = aaaa[0]
y = aaaa[1]
z = aaaa[2]
sousa = 0

if (3 * m) % 2 == (a + b + c) % 2:
    truemax = m    
else:
    truemax = m + 1
    
    
while x <= truemax:
    sousa = sousa + 1
    x = x + 2
    
while y <= truemax:
    sousa = sousa + 1
    y = y + 2
    
b = list(sorted([x,y,z]))

xx = b[0]
yy = b[1]
zz = b[2]
    
sousa = sousa + (3 * truemax -xx -yy -zz) //2
print(sousa)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t, a=0, m=0, k=5;
    while (k--) {
        cin >> t;
        a += (t+9)/10*10;
        m = max(m, (990-t)%10);
    }
    cout << a-m << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;++i)
int main(){
int n,a=0;cin>>n;
vector<string>g(n),h(n);
r(i,n)cin>>g[i];
r(i,n){r(j,n)h[(j+i)%n]=g[j];int f=1;
r(p,n){r(q,p){if(h[p][q]!=h[q][p])f=0;}}
if(f)a+=n;}
cout<<a<<endl;
return 0;
}

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

int main(){
   int a,b;
   cin >> a >> b;
   if(a<b){
      cout << "a < b" <<endl;
   }
   if(a>b){
      cout << "a > b" <<endl;
   }
   if(a==b){
      cout << "a == b" <<endl;
   }
   return 0;
}

Measured memory_bytes: 3020
fun main(arr:Array<String>) {
    val num = readLine()!!.replace(" ", "").toInt()
    println(if(isSquare(num)) "Yes" else "No")
}

fun isSquare(num:Int):Boolean {
    for(i in (2..num)) {
        if(i*i == num) {
            return true
        }
        if(i*i > num) {
            break
        }
    }
    return false
}

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

int main() {
  int N,i,j,flag,cou=0;
  cin>>N;
  vector<int> d(N);
  for(i=0;i<N;i++){
    flag=1;
    cin>>d[i];
    for(j=0;j<i;j++){
      if(d[i]==d[j]){
        flag=0;
        break;
      }
    }
    if(flag)cou++;
  }
  cout<<cou<<endl;
}


Measured memory_bytes: 256
#include <iostream>
 using namespace std;
 int main(){
 string S;
 cin >> S;
 int L = S.size();
 string ans = "AC";
 if(S[0] != 'A'){
 ans = "WA";
 }
 int cnt = 0;
 for(int i = 1; i < L; ++i){
 if(isupper(S[i])){
 if(i == 1 || i == L - 1 || S[i] != 'C'){
 ans = "WA";
 }
 ++cnt;
 }
 }
 if(cnt != 1){
 ans = "WA";
 }
 cout << ans << endl;
 }


Measured memory_bytes: 256