akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const string color = "RYGB";

int H,W,d;

int main() {
    cin>>H>>W>>d;
    for (int h=0;h<H;h++) {
        for (int w=0;w<W;w++) {
            int d1 = h+w;
            int d2 = h-w+W-1;
            int num = d1/d % 2 + d2/d % 2  * 2;
            cout << color[num];
        }
    cout<<endl;
    }
}




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

long long combination(long long n, long long r) {
  if ( r * 2 > n ) r = n - r;
  long long divided = 1;
  long long divisor  = 1;
  for (long long i = 1; i <= r; ++i ) {
    divided = divided * (n-i+1);
    divisor  = divisor * i;
  }
  return divided / divisor;
}


int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i=0; i<N; i++){
    cin >> S[i];
  }
  for (int i=0; i<N; i++){
    sort(S[i].begin(), S[i].end());
  }

  // vector<vector<int>> alph_cnt(N, vector<int>(26, 0));
  //
  // for (int i=0; i<N; i++){
  //   for (int j=0; j<10; j++){
  //     int k = S[i][j] - 'a';
  //     alph_cnt[i][k]++;
  //   }
  // }
  // int ans=0;
  // for (int i=0; i<N; i++){
  //   for (int j=i+1; j<N; j++){
  //     if (equal(alph_cnt[i].cbegin(), alph_cnt[i].cend(), alph_cnt[j].cbegin())){
  //       ans++;
  //     }
  //   }
  // }
  // int cnt = 1;
  // vector<string> s_list(N);
  // s_list[0] = S[0];
  // for (int i=1; i<N; i++){
  //   for (int j=0; j<cnt; j++){
  //     if (S[i] == s_list[j]){
  //       break;
  //     }
  //     s_list[cnt] = S[i];
  //     cnt++;
  //   }
  // }

  sort(S.begin(), S.end());
  // for (int i=0; i<N;i++){
  //   cout << S[i] << endl;
  // }
  int cnt = 1;
  vector<int> num(N, 1);
  // for (int i=0; i<N;i++){
  //   cout << num[i] << endl;
  // }
  for (int i=1; i<N; i++){
    if (S[i-1] == S[i]){
      num[cnt-1]++;
    } else{
      cnt++;
    }
  }
  // for (int i=0; i<cnt; i++){
  //   cout << num[i] << endl;
  // }
  // cout << endl;
  // cnt の数だけ異なるやつがあって、それぞれ num[cnt]個揃ってる
  // 組み合わせの数は num[cnt]_C_2
  long long ans = 0;
  for (int i=0; i<cnt; i++){
    if (num[i] != 1){
      ans += combination((long long)num[i], 2);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7680
#include <cstdio>
#include <vector>
#include <utility>
#include <set>
#include <algorithm>

using namespace std;
typedef pair<int,int> PII;

int np = 0;
int N;
struct Tree{
  int loc, l, r;
};
Tree T[500000+1];
struct P{
  int id, x, y;
};
P ps[500000+1];

int mk2DTree(int l, int r, int depth){
  if(r <= l) return -1;
  int mid = (l + r) / 2;

  int t = np++;
  if(depth % 2)
	sort(ps+l, ps+r, [](const P& lh, const P& rh){return lh.x < rh.x;});
  else
	sort(ps+l, ps+r, [](const P& lh, const P& rh){return lh.y < rh.y;});

  T[t].loc = mid;
  T[t].l = mk2DTree(l, mid, depth+1);
  T[t].r = mk2DTree(mid+1, r, depth+1);

  return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, set<int>& s){
  int x = ps[T[v].loc].x;
  int y = ps[T[v].loc].y;

  if(sx <= x && x <= tx && sy <= y && y <= ty)
	s.insert(ps[T[v].loc].id);

  if(depth % 2){
	if(T[v].l != -1 && sx <= x)
	  find(T[v].l, sx, tx, sy, ty, depth+1, s);
	if(T[v].r != -1 && x <= tx)
	  find(T[v].r, sx, tx, sy, ty, depth+1, s);	
  }
  else{
	if(T[v].l != -1 && sy <= y)
	  find(T[v].l, sx, tx, sy, ty, depth+1, s);
	if(T[v].r != -1 && y <= ty)
	  find(T[v].r, sx, tx, sy, ty, depth+1, s);
  }
}

int main(){
  scanf("%d", &N);
  for(int i=0;i<N;++i){
	scanf("%d %d", &ps[i].x, &ps[i].y);
	ps[i].id = i;
  }
  mk2DTree(0, N, 0);
  int Q; scanf("%d", &Q);
  while(Q--){
	int sx, tx, sy, ty;
	scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
	set<int> s;
	find(0, sx, tx, sy, ty, 0, s);
	for(int x: s)
	  printf("%d\n", x);
	printf("\n");
  }
  
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    int c; cin>>c;
    vector<vi> D(c, vi(c));
    rep(i,c)rep(j,c) cin>>D[i][j];
    vector<vi> E(3, vi(c));
    rep(i,n)rep(j,n){
        int x; cin>>x; x--;
        E[(i+j)%3][x]++;
    }
    ll ans=LONG_LONG_MAX;
    rep(i,c)rep(j,c)rep(k,c){
        if (i==j || j==k || k==i) continue;
        ll sum=0;
        rep(l,c){
            sum += (ll)E[0][l]*D[l][i];
            sum += (ll)E[1][l]*D[l][j];
            sum += (ll)E[2][l]*D[l][k];
        }
        chmin(ans,sum);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
  int n,c=0;
  cin>>n;
  int a[n];
  for(int i=1;i<=n;++i)
  {cin>>a[i];}
  for(int i=1;i<=n;++i)
  {
    if(a[i]%2!=0 && i%2!=0)
      c++;
  }
  cout<<c<<endl;
  return 0;
}

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

int main(){
	int j = 0;
	int n;
	cin >> n;
	vector<int> a(n),b(n);

	for(auto& s : a){
		cin >> s;
	}
	
	if(n % 2 == 1){
		b[a.size() / 2] = a[j++];
		for(size_t i = 1; i <= a.size() / 2; ++i){
			b[a.size() / 2 + i] = a[j++];
			b[a.size() / 2 - i] = a[j++];
		}
	} else{
		b[a.size() / 2] = a[j++];
		for(size_t i = 1; i < a.size() / 2; ++i){
			b[a.size() / 2 - i] = a[j++];
			b[a.size() / 2 + i] = a[j++];
		}
		*(b.begin()) = *(a.end() - 1);
	}

	for(size_t i = 0; i < b.size() - 1; ++i){
		cout << b[i] << ' ';
	}
	cout << b[b.size()-1] << endl;

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);
  string correct = "CODEFESTIVAL2016";

  int i = 0;
  int ans = 0;
  for (auto e : s) {
    if (s.at(i) != correct.at(i)) ans++;
    i++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
L = [list(map(int,input().split())) for k in range(N)]
L = sorted(L)
ans = 0

for k in range(N):
    if M >= L[k][1]:
        ans += L[k][0]*L[k][1]
        M -= L[k][1]
        if M == 0:
            print(ans)
            exit(0)
    elif M < L[k][1]:
        ans += L[k][0]*M
        print(ans)
        exit(0)


Measured memory_bytes: 28656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split(" ");
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        int c = Integer.parseInt(s[2]);
        int k = Integer.parseInt(scanner.nextLine());
        boolean success = false;
        for (int i = 0; i < k; i++) {
            if (a < b) {
                c *= 2;
                if (b < c) {
                    success = true;
                }
            } else {
                b *= 2;
            }
        }
        if (success) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        scanner.close();
    }
}

Measured memory_bytes: 27028
#include <iostream>

using namespace std;

unsigned long long lcm(unsigned long long x, unsigned long long y)
{
	unsigned long long a = x * y;
 
	if (x < y) {
		unsigned long long tmp = x;
		x = y;
		y = tmp;
  }
 
	unsigned long long r = x % y;
  	while (r!=0) {
		x = y;
		y = r;
		r = x % y;
	}
	return a / y;
}

int main(int argc, char *argv[])
{
	unsigned long long A, B, C, D;
	unsigned long long c, d, cd;
	cin >> A >> B >> C >> D;

	c = (B / C) - ((A - 1) / C);
	d = (B / D) - ((A - 1) / D);
	unsigned long long  CD = lcm(C, D);
	cd = (B / CD) - ((A - 1) / CD);
	cout << (B - A + 1) - c - d + cd << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
inline void solve() {
    int d, t, s; cin >> d >> t >> s;
    int to = ceil((double)d / s);
    if (to <= t) {
        cout << "Yes\n";
        return;
    }
    cout << "No\n";
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3760
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3520
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val l = sc.nextLong()
  val r = sc.nextLong()

  var ans = Long.MAX_VALUE
  for (i in l..r-1) {
    for (j in l+1L..r) {
      val ij = i * j
      val tmp = ij % 2019L
      if (tmp == 0L) {
        println(0)
        return
      }
      if (tmp < ans) {
        ans = tmp
      }

    }
  }
  println(ans)
}


Measured memory_bytes: 36388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll elem[1050];
vector<char>ans;
int main()
{
   ll n;
   cin>>n;
   while(n)
   {
       ans.push_back('a'-1+(n-1)%26+1);
       n=(n-1)/26;
   }
   for(ll i=0;i<ans.size();i++)
   {
       cout<<ans[ans.size()-i-1];
   }
}


Measured memory_bytes: 3548
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
fact = math.factorial
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

H,W = I()
maze = []
for i in range(H):
    a = l()
    if i%2 == 1:
        a.reverse()
    for j in range(W):
        maze.append(a[j])
ans = []
zahyo = []
for i in range(H*W):
    b = i//W+1
    c = i%W+1
    if b%2 == 0:
        c = W-c+1
    zahyo.append([b,c])
for i in range(H*W-1):
    if maze[i]%2 == 1:
        ans.append(zahyo[i]+zahyo[i+1])
        maze[i+1] += 1
print(len(ans))
for s in ans:
    print(*s)

Measured memory_bytes: 126268
import java.util.*;
import java.awt.geom.*;
import java.awt.geom.Point2D.Double;

import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new Q2007I();
	}
	
	Point2D intersectionPoint(Line2D l1,Line2D l2){
		return intersectionPoint(l1.getP1(), l1.getP2(), l2.getP1(), l2.getP2());
	}
	Point2D intersectionPoint(Point2D a1,Point2D a2,Point2D b1,Point2D b2){
		Point2D a=diff(a2,a1),
				b=diff(b2,b1);
		return sum(a1, mul(cross(b, diff(b1,a1))/cross(b,a), a));
	}
	Point2D diff(Point2D p1,Point2D p2){
		return new Point2D.Double(p1.getX()-p2.getX(), p1.getY()-p2.getY());
	}
	double cross(Point2D p1,Point2D p2){
		return p1.getX()*p2.getY() - p2.getX()*p1.getY();
	}
	Point2D mul(double n,Point2D p1){
		return new Point2D.Double(p1.getX()*n, p1.getY()*n);
	}
	Point2D sum(Point2D p1,Point2D p2){
		return new Point2D.Double(p1.getX()+p2.getX(), p1.getY()+p2.getY());
	}
	private ArrayList<Point2D> polygonCut(ArrayList<Point2D> plist, Line2D cut) {
		int n = plist.size();
		ArrayList<Point2D> ans = new ArrayList<Point2D>();
		for(int i =0; i<n; i++){
			Point2D from = plist.get(i), to = plist.get((i+1)%n);
			if(cut.relativeCCW(from) <= 0){
				ans.add(from);
			}
			int temp1 = cut.relativeCCW(from);
			int temp2 = cut.relativeCCW(to);
			if(temp1 * temp2 < 0){
				Point2D IntersectP = intersectionPoint(cut, new Line2D.Double(from,to));
				ans.add(IntersectP);
			}
		}
		return ans;
	}
	
	class Q2007I{
		int N;
		Q2007I(){
			while(true){
				N=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		void solve(){
			int[] x=new int[N],
					y=new int[N];
			for(int i=0; i<N; ++i){
				x[i]=sc.nextInt();
				y[i]=sc.nextInt();
			}
			
			double ret = f1(x,y);
			System.out.printf("%.7f\n" ,ret);
			
		}
		final double EPS = 1.0e-7;
		double f1(int[] x,int[] y){
			double l=0, r=30000;
			while(abs(r-l) > EPS){
				double mid = (l+r)/2;
				ArrayList<Point2D> tmp = new ArrayList<Point2D>(N);
				for(int i=0; i<N; ++i){
					tmp.add(new Point2D.Double(x[i], y[i]));
				}
				boolean flg = f2(tmp, mid);	// true = 沈む false = 残る
				if(flg)	r=mid;
				else	l=mid;
			}
			return r;
		}
		
		boolean f2(ArrayList<Point2D> ps, double d){
			
			Line2D.Double[] cuts = new Line2D.Double[ps.size()];
			for(int i=0; i<ps.size(); ++i){
				Point2D p1 = ps.get(i),
						p2 = ps.get((i+1)%ps.size());
				double x = -(p2.getY()-p1.getY()),
						y = (p2.getX()-p1.getX());
				double d2 = p1.distance(p2);
				x = x*d/d2;	y=y*d/d2;
				Point2D v1 = new Point2D.Double(x,y);
				cuts[i] = new Line2D.Double(sum(p1, v1), sum(p2, v1));
			}
			
			for(Line2D.Double cut: cuts){
				ps = polygonCut(ps, cut);
			}
			
//			System.out.println("D:"+d+" ps:"+ps.size());
			
			return ps.isEmpty();
			
		}
	}
}

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

//const int M = 1e18+7;

vector<int> adj[100005] , vis(100005 , 0) , tsort;

void dfs(int root) {
    vis[root] = 1;
    for(int i = 0; i < adj[root].size(); i++) {
        int u = adj[root][i];
        if(!vis[u]) dfs(u);
    }
    tsort.push_back(root);
}

void top_sort(int n) {
    for(int i = 1; i <= n; i++) {
        if(!vis[i]) dfs(i);
    }
    reverse(tsort.begin() , tsort.end());
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n , m , u , v;
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
    }
    top_sort(n);
    int dp[n+1] = {0};
    for(int i = 0; i < tsort.size(); i++) {
        u = tsort[i];
        for(int j = 0; j < adj[u].size(); j++) {
            v = adj[u][j];
            dp[v] = max(dp[v] , 1 + dp[u]);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans , dp[i]);
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 9080
#include<iostream>
#include<cstdio>
#include<algorithm>
#define maxn 100005
#define nil -1
using namespace std;
int n,root;

struct node
{
	int parent;
	int left;
	int right;
	int depth;
	int height;
	node():parent(nil),left(nil),right(nil){}
};
node t[maxn];

int Max(int a,int b)
{
	return a>b?a:b;
}

void build()
{
	for(int i=0;i<n;++i)
	{
		int num,l,r;
		scanf("%d%d%d",&num,&l,&r);
		t[num].left=l;
		t[num].right=r;
		if(l!=nil) t[l].parent=num;
		if(r!=nil) t[r].parent=num;
	}
	return;
}

void find_root()
{
	for(int i=0;i<n;++i)
	  if(t[i].parent==nil)
	  {
	  	root=i;
	  	break;
	  }
	return ;
}

int find_sibling(int num)
{
	int p=t[num].parent;
	if(p==nil) return nil;
	if(t[p].left==num&&t[p].right!=nil) return t[p].right;
	if(t[p].right==num&&t[p].left!=nil) return t[p].left;
	return nil;
}

int get_degree(int num)
{
	int p=0;
	if(t[num].left!=nil) p++;
	if(t[num].right!=nil) p++;
	return p;
}

void get_depth(int num,int d)
{
	t[num].depth=d;
	if(t[num].left!=nil) get_depth(t[num].left,d+1);
	if(t[num].right!=nil) get_depth(t[num].right,d+1);
}

int get_height(int num)
{
	int h1=0,h2=0;
	if(t[num].left!=nil) 
	  h1=get_height(t[num].left)+1;
	if(t[num].right!=nil)
	  h2=get_height(t[num].right)+1;
	t[num].height=Max(h1,h2);
	return t[num].height;
}

void print(int num)
{
	printf("node %d: ",num);
	printf("parent = %d, ",t[num].parent);
	printf("sibling = %d, ",find_sibling(num));
	printf("degree = %d, ",get_degree(num));
	printf("depth = %d, ",t[num].depth);
	printf("height = %d, ",t[num].height);
	if(t[num].parent==nil) printf("root\n");
	else if(t[num].left==nil&&t[num].right==nil) printf("leaf\n");
	else printf("internal node\n");
	return ;
}

int main()
{
	scanf("%d",&n);
	build();
	find_root();
	get_depth(root,0);
	get_height(root);
	for(int i=0;i<n;++i)
	  print(i); 
	return 0;
}

Measured memory_bytes: 5164
function bomb(y,x,color){
   var dy=[-1,0,0,1];
   var dx=[0,-1,1,0];
   for(var i=0;i<4;i++){
      var yy=y+dy[i];
      var xx=x+dx[i];
      if(yy<0 || xx<0 || yy>=12 || xx>=6)continue;
      if(yx[yy][xx]==color) {
         CNT++;
         if(CNT==4)p.push([yy,xx]);
         yx[yy][xx]=color+CNT;
         bomb(yy,xx,color);
      }
   }
}
function BOMB(y,x,color){
   var dy=[-1,0,0,1];
   var dx=[0,-1,1,0];
   for(var i=0;i<4;i++){
      var yy=y+dy[i];
      var xx=x+dx[i];
      if(yy<0 || xx<0 || yy>=12 || xx>=6)continue;
      if(yx[yy][xx]==color){
         yx[yy][xx]=".";
         BOMB(yy,xx,color);
      }else if(yx[yy][xx]=="O"){
         yx[yy][xx]=".";
      }
   }
}
function up(y,x){
   var yy=y;
   while(y>0){
      y--;
      if(yx[y][x]!="."){
         yx[yy][x]=yx[y][x];
         yx[y][x]=".";
         break;
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var yx=[];
   for(var i=0;i<12;i++){
      var arr=(Arr.shift()).split("");
      yx.push(arr);
   }
   var result=0;  
   while(true){
        var p=[];
        var CNT;
         for(var i=0;i<12;i++){
               for(var j=0;j<6;j++){
                  if(yx[i][j]=="R"){CNT=1;yx[i][j]="R"+CNT;bomb(i,j,"R");}
                  if(yx[i][j]=="G"){CNT=1;yx[i][j]="G"+CNT;bomb(i,j,"G");}
                  if(yx[i][j]=="B"){CNT=1;yx[i][j]="B"+CNT;bomb(i,j,"B");}
                  if(yx[i][j]=="Y"){CNT=1;yx[i][j]="Y"+CNT;bomb(i,j,"Y");}
                  if(yx[i][j]=="P"){CNT=1;yx[i][j]="P"+CNT;bomb(i,j,"P");}
               }
         }
         for(var i=0;i<12;i++){
            for(var j=0;j<6;j++){
               yx[i][j]=yx[i][j].slice(0,1);
            }
         }
         if(p.length==0)break;
         result++; 
         p.forEach(function(v){
            var i=v[0];
            var j=v[1];
            var color=yx[i][j];
            if(color!=".")BOMB(i,j,color);
         });
         for(var i=11;i>0;i--){
            for(var j=0;j<6;j++){
               if(yx[i][j]==".")up(i,j);
            }
         }
   }
   console.log(result);
}

Measured memory_bytes: 9800
/*
srt: 2017年06月19日 19時50分00秒
 《寄左省杜拾遗》岑参
联步趋丹陛，分曹限紫微。
晓随天仗入，暮惹御香归。
白发悲花落，青云羡鸟飞。
圣朝无阙事，自觉谏书稀。
end: 2017年06月19日 19時57分51秒
*/

#include<cstdio>
#include<bitset>
inline void read(int&r)
{
	register char c;r=0;
	do c=getchar();while(c<'0'||c>'9');
	do r=r*10+c-'0',c=getchar();while(c>='0'&&c<='9');
}

bool b[401];
std::bitset<401>a[401];
int x[100001],y[100001];
int main()
{
	int i,j,n,m,s=0;read(n),read(m);
	for(i=1;i<=m;i++)read(x[i]),read(y[i]);
	for(i=1;i<=n;i++)
		for(j=m,a[i][i]=true;j;j--)
			if(a[i][j[x]]&&a[i][j[y]])
			{ b[i]=true;break; }
			else if(a[i][j[x]])a[i][j[y]]=true;
			else if(a[i][j[y]])a[i][j[x]]=true;
	for(i=1;i<=n;i++)
		if(!b[i])
			for(j=1;j<i;j++)
				if(!b[j]&&(a[i]&a[j]).none())
					s++;
	printf("%d\n",s);
}

Measured memory_bytes: 1024
package main

import (
    "fmt"
	"sort"
)

func main() {
    var n int
    fmt.Scan(&n)

	a := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
	}
	tmp := make([]int, n)
	for idx, value := range(a) {
		tmp[idx] = value
	}
    sort.Ints(a)
	max1 := a[len(a)-1]
	max2 := a[len(a)-2]

	for _, x := range(tmp) {
		if max1 == max2 {
			fmt.Println(max1)
		} else {
			if x != max1 {
				fmt.Println(max1)
			} else { 
				fmt.Println(max2)
			}
		}
	}
}

Measured memory_bytes: 8064
from collections import deque


class Edge:
    def __init__(self, to, flow, cap, rev, is_rev):
        self.to = to
        self.flow = flow
        self.cap = cap
        self.rev = rev
        self.is_rev = is_rev


class Dinic:
    def __init__(self, num_of_node: int):
        assert num_of_node > 0

        self.graph = [list() for _ in range(num_of_node)]   # グラフの隣接リスト表現
        self.level = [None] * num_of_node      # sからの距離
        self.ite = [None] * num_of_node       # どこまで調べ終わったか

    # fromからtoへ向かう容量capの辺をグラフに追加する
    def add_edge(self, f: int, t: int, cap: int):
        self.graph[f].append(Edge(t, 0, cap, len(self.graph[t]), False))
        self.graph[t].append(Edge(f, cap, cap, len(self.graph[f]) - 1, True))

    # sからtへの最大流を求める
    def max_flow(self, s: int, t: int):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] < 0:
                return flow

            self.ite = [0] * len(self.ite)
            while True:
                f = self.dfs(s, t, 10 ** 10)
                if f > 0:
                    flow += f
                else:
                    break

    # sからの最短距離をBFSで計算する
    def bfs(self, s: int):
        self.level = [-1] * len(self.level)
        que = deque()
        que.append(s)
        self.level[s] = 0
        while len(que):
            v = que.popleft()

            for i in range(len(self.graph[v])):
                e = self.graph[v][i]
                if e.cap - e.flow > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[v] + 1
                    que.append(e.to)

    # 増加パスをDFSで探す
    def dfs(self, v: int, t: int, f: int):
        if v == t:
            return f

        for i in range(self.ite[v], len(self.graph[v])):
            e = self.graph[v][i]
            if e.cap - e.flow > 0 and self.level[v] < self.level[e.to]:
                d = self.dfs(e.to, t, min(f, e.cap - e.flow))
                if d > 0:
                    self.graph[v][i].flow += d
                    self.graph[e.to][e.rev].flow -= d
                    return d
            self.ite[v] = i
        return 0


def main():
    V, E = map(int, input().split())
    dinic = Dinic(V)
    for _ in range(E):
        u, v, c = map(int, input().split())
        dinic.add_edge(u, v, c)

    print(dinic.max_flow(0, V - 1))


if __name__ == '__main__':
    main()



Measured memory_bytes: 6340
H,W = map(int,input().split())
S = ["."*(W+2)]+["."+input()+"." for h in range(H)]+["."*(W+2)]

for h in range(1,H):
  for w in range(1,W):
    if S[h][w]=="#" and S[h-1][w]=="." and S[h+1][w]=="." and S[h][w-1]=="." and S[h][w+1]==".":
      print("No")
      exit()
      
print("Yes")

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int H,W;
    cin >> H >> W;
    char s[53][53];
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> s[i][j];
        }
    }
    string ans="Yes";
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(s[i][j]=='#'){
                if(s[i-1][j]!='#' && s[i+1][j]!='#' && s[i][j-1]!='#' && s[i][j+1]!='#'){
                    ans="No";
                }
            }
        }
    }
    cout << ans<< endl;


}


Measured memory_bytes: 256
import math

N, X = map(int, input().split())
l = []
for i in range(N):
    l.append(input())
l = list(map(int, l))
m = min(l)
index = l.index(m)
del l[index]
M = math.floor((X-sum(l))/m)
print(str(M+N-1))

Measured memory_bytes: 3064
#include<cstdio>
#include<map>
using namespace std;
int main()
{
	int n,a;
	scanf("%d",&n);
	map<int,int> m;
	while(n--)
	{
		scanf("%d",&a);
		m[a]++;
	}
	int r=0,c=0;
	for(auto i:m)
		if(i.second>3)r=c=i.first;
		else if(i.second>1)c=r,r=i.first;
	printf("%lld\n",(long long)r*c);
}


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

public class Remainder
{
    static int[] PrimeFactors;

    static public void Main()
    {
        var HA = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        
        var H = HA[0];
        var A = HA[1];
        

        Console.WriteLine((H-1)/A+1);

    }

    static void PublicFactorization(int n)
    {
        int i = 2;
        int tmp = n;

        while(i*i <= n)
        {
            if(tmp % i == 0)
            {
                tmp /= i;
                PrimeFactors[i]++;
            }
            else
            {
                i++;
            }
        }

        if(tmp != 1)
        {
            PrimeFactors[tmp]++;
        }
    }

}


Measured memory_bytes: 11220
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    _max = max
    _min = min
    for _ in range(k):
        C = [0] * n
        i = 0
        for a in A:
            l = _max(0, i - a)
            r = _min(n, i + a + 1)
            C[l] += 1
            if r < n:
                C[r] -= 1
            i += 1
        r = 0
        for i in range(n):
            r += C[i]
            A[i] = r
        if A == [n] * n:
            break
    print(" ".join(map(str, A)))
main()

Measured memory_bytes: 127456
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


void findUf(ll c,ll n,vll uf,vll score,vll & ans) {
	ans[c] += score[uf[n]];
	if (uf[n] > 1) {
		findUf(c, uf[n], uf, score,ans);
	}
}

int main() {
	ll h,w,d,q,tmp,l,r;
	in(h);
	in(w);
	in(d);

	vector<vll> a(h * w+1, vll(2));
	vll  score(h*w+1,0);
	map<ll, ll> root;
	repeq(i, 1,h) {
		repeq(j, 1, w) {
			in(tmp);
			a[tmp][0] = i;
			a[tmp][1] = j;
		}
	}

	repeq(i, d+1, h*w) {
		score[i] = score[i - d] + abs(a[i][0] - a[i - d][0]) + abs(a[i][1] - a[i - d][1]);
	}


	in(q);
	rep(i, 0, q) {
		in(l);
		in(r);
		outn(score[r] - score[l]);

	}


	return 0;
}


Measured memory_bytes: 6784
#include<iostream>
#include<map>
using namespace std;
int main(){
    int n,i,count=0,tmp;
    cin>>n;
    map<int,int> mp;
    for(i=0;i<n;i++){
        cin>>tmp;
        mp[tmp]++;
    }
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        if(itr->first<itr->second)
            count+=(itr->second-itr->first);
        else if(itr->first>itr->second)
            count+=itr->second;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 4736
/**
 *   author: r1933
**/
#include "bits/stdc++.h"

using namespace std;

#define all(x) x.begin(), x.end()
using i64 = long long;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string res = "";
  for (int i = 0; i < s.length() - 8; ++i) {
    res += s[i];
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    h, w = map(int, input().split())

    s = []
    for _ in range(h):
        s.append(list(input())[:-1])

    ans = 0

    from collections import deque
    import copy

    reach_queue = deque()
    next_queue = deque()

    not_visited = [[True]*w for _ in range(h)]

    for i in range(w):
        for j in range(h):
            if s[j][i] == '.':
                next_queue.append((i, j))
                not_visited = [[True]*w for _ in range(h)]
                not_visited[j][i] = False
                cnt = -1
                while True:
                    if len(next_queue) == 0:
                        ans = max([ans, cnt])
                        break
                    reach_queue = copy.deepcopy(next_queue)
                    next_queue = deque()
                    while True:
                        if len(reach_queue) == 0:
                            cnt += 1
                            break
                        new_i, new_j = reach_queue.popleft()
                        if new_i != 0:
                            if s[new_j][new_i-1] == '.' and not_visited[new_j][new_i-1]:
                                not_visited[new_j][new_i-1] = False
                                next_queue.append((new_i-1, new_j))
                        if new_j != 0:
                            if s[new_j-1][new_i] == '.' and not_visited[new_j-1][new_i]:
                                not_visited[new_j-1][new_i] = False
                                next_queue.append((new_i, new_j-1))
                        if new_i != w-1:
                            if s[new_j][new_i+1] == '.' and not_visited[new_j][new_i+1]:
                                not_visited[new_j][new_i+1] = False
                                next_queue.append((new_i+1, new_j))
                        if new_j != h-1:
                            if s[new_j+1][new_i] == '.' and not_visited[new_j+1][new_i]:
                                not_visited[new_j+1][new_i] = False
                                next_queue.append((new_i, new_j+1))

    print(ans)


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


int main() {
  long long N;
  long long K;
  cin >> N >> K;
  vector <long long> vec(N);
  for (long long i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
 
  long long count=0;
  long long sum=0;
  if (N >=K)  {
  for (long long i=0; i<N-K; i++) {
    sum +=vec.at(i);
  }
  cout << sum << endl;
  }
  else if ((N <K) && (K !=0)) {
    cout << "0" << endl;
  }
 
}

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

int main() {
  int n;
  cin>>n;
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)cout<<"hon"<<endl;
  else if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon"<<endl;
  else cout<<"bon"<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cmath>

using namespace std;

int main(){

int n=0,x=0;
int count=0;

while(1){
  cin >> n >> x;
  if(n==0 && x==0) break;              //???????????????
  count=0;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      for(int k=j+1;k<=n;k++){
        if( i + j + k == x){            //????????????????????¶??§??¢?´¢
          count++;
        }

      }
    }
  }
  cout << count << endl;
}



return 0;


}

Measured memory_bytes: 1160
const int LG = 21;
const int FN = 400005;
const long long MOD = 998244353;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

const int N = 1100000;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m, k;
    cin >> n;
    vi a(2 * n);
    forn(i, 2 * n) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    forn(i, n) ans += min(a[2 * i], a[2 * i + 1]);
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}



int main2() {
  int a[3];
  REP(i, 3) cin >> a[i];
  sort(a, a+3);
  if (a[0] == a[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,n,p[21];
	int cnt=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	for(i=2;i<n;i++)
	{
		if(p[i-1]<p[i] && p[i]<p[i+1])
		{
			cnt++;
		}
		if(p[i+1]<p[i] && p[i]<p[i-1])
		{
			cnt++;
		}
	}
	printf("%d",cnt);
	return 0;
}



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

using namespace std;

int arr[200005];
vector<int>path ;

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

    int n;
    cin>>n;

    long long k;
    cin>>k;


    for(int i = 1;i<=n;i++)cin>>arr[i];


    path.push_back(1);
    map<int,int>mark;  //mark[i]=last move where i has been occured last time
    mark[1]=path.size();

    int cur = 1; //as initially we are in 1
    for(int i=0;i<n;i++){
        cur=arr[cur];
        if(mark[cur]>0){

            vector<int>cycle;
            for(int j=mark[cur]-1;j<path.size();j++){
                cycle.push_back(path[j]);
            }
            long long sz = cycle.size();
            long long v = path.size();
            k-=(v-sz);
            if(k<=0){
                k+=(v-sz);

                cout<<path[k]<<"\n";
                return 0;
            }

            k%=sz;
            cout<<cycle[k]<<"\n";
            return 0;
        }
        path.push_back(cur);
        mark[cur]=path.size();

    }
}


Measured memory_bytes: 15012
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    for(int i=9 ; i>0 ; i--){
      if(n%i==0){
        if(1<=n/i && n/i<=9){
          System.out.println("Yes");
          break;
        }
      }else{
        continue;
      }
      System.out.println("No");
      break;
    }
  }
}


Measured memory_bytes: 23508
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, m;
    cin >> n >> m;

    bool red[n];
    int cnt[n];
    fill(red, red+n, false);
    fill(cnt, cnt+n, 1);
    red[0] = true;

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        cnt[x]--; cnt[y]++;
        if (red[x]) red[y] = true;
        if (cnt[x] == 0) red[x] = false;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (red[i]) ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 768
N=int(input())
if N%10==2: 
  print('hon')
elif N%10==4:
  print('hon')
elif N%10==5:
  print('hon')
elif N%10==7:
  print('hon') 
elif N%10==9:
  print('hon')  
elif N%10==0: 
  print('pon')
elif N%10==1: 
  print('pon')
elif N%10==6: 
  print('pon')
elif N%10==8: 
  print('pon')  
elif N%10==3:
  print('bon')

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

const double PI = acos(-1.0);

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ha = (double)(h*60 + m)/720*(PI*2);
    double ma = (double)m/60*(PI*2);
    double angle = ha - ma;
    double ans = sqrt(a*a+b*b-2.0*a*b*cos(angle));
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4052
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: i32,
    );

    let mut ans = "No";

    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                ans = "Yes";
            }
        }
    }

    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)
#define COS 2000005

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<bool> b(COS,false);
	ll i, j;
	ll ans = 0;

	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	rep(i, n - 1) {
		if (b[a[i]] == true)continue;
		if (a[i] == a[i + 1]) {
			b[a[i]] = true;
			//continue;
		}
		for (j = 2; j < a[n - 1] / a[i] + 1; j++) {
			b[j * a[i]] = true;
		}
	}
	rep(i, n) {
		if (b[a[i]] == false)ans++;
	}
	cout << ans << endl;




	return 0;
}


Measured memory_bytes: 4988
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

  int h,n;
  vector<int> a(1010),b(1010);
  vector<int> dp(mx,inf);

int rec(int m){
  if(m<=0) return dp[0] = 0;
  if(dp[m]!=inf) return dp[m];
  int res = inf;
  rep(i,n) res = min(res,rec(m-a[i])+b[i]);
  return dp[m] = res;
}

int main() {
  cin >> h >> n;
  rep(i,n) cin >> a[i] >> b[i];
  int ans = rec(h);
  cout << ans << endl;
  return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define mp make_pair
#define INF 1e18
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    double arr[n];
    For(i, 0, n) cin >> arr[i];
    double pbb[n][n + 1];
    For(i, 0, n)
    {
        For(j, 0, n + 1)
        {
            pbb[i][j] = 0;
        }
    }
    pbb[0][0] = 1 - arr[0];
    pbb[0][1] = arr[0];
    For(i, 1, n) pbb[i][0] = pbb[i - 1][0] * (1 - arr[i]);
    For(i, 1, n)
    {
        For(j, 1, n + 1)
        {
            pbb[i][j] = pbb[i - 1][j - 1] * arr[i] + (pbb[i - 1][j] * (1 - arr[i]));
        }
    }
    // For(i, 0, n + 1)
    // {
    //     For(j, 0, n)
    //     {
    //         cout << setw(4) << pbb[j][i] << " ";
    //     }
    //     cout << endl;
    // }
    double res = 0;
    For(i, (n / 2) + 1, n + 1)
    {
        res += pbb[n - 1][i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 74088
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int arr[]=new int[2];
    for(int i=0;i<2;i++)
    {
      arr[i]=in.nextInt();
    }
    Arrays.sort(arr);
    int mid=0,i=1;
    while(mid<=arr.length-1)
    {
      if(arr[mid]!=i)
      {
        System.out.println(i);
        System.exit(0);
      }
      mid++;
      i++;
    }
    System.out.println("3");
  }
}

Measured memory_bytes: 35764
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main()
{
	int n;
	cin>>n;
	int ans = 0;
	int *numArray = new int[n];
	for(int i = 0; i < n; i++){
		cin>>numArray[i];
	}
	//左側が全部自分よりも大きい
	int minNum = numArray[0];
	for(int i = 0; i < n; i++){
		if( numArray[i] <= minNum){
			ans++;
		}
		minNum = min(minNum,numArray[i]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
const int MAXB = 10;  // Base representation.
const int MAXD = 105;
const int MAXN = 1e4+5;
const int MOD = 1e9+7;
const int NOPE = -1;
char K[MAXN];
int dp[MAXN][MAXD][2]{ };
int D, N;

// dp[i][j] = numbers of length i and digit sum j (mod D).

int dfs(int pos, int sum, bool less) {
  if (dp[pos][sum][less] != NOPE) {
    return dp[pos][sum][less];
  }
  if (pos == N) {
    return dp[pos][sum][less] = (sum == 0) ? 1 : 0;
  }
  int ans = 0;
  int val = K[pos] - '0';
  int end = (less) ? MAXB : (val + 1);
  for (int i = 0; i < end; ++i) {
    int nsum = (1LL * sum + i) % D;
    bool nless = less || (i < val);
    ans = (1LL * ans + dfs(pos + 1, nsum, nless)) % MOD;
  }
  return dp[pos][sum][less] = ans;
}

void init() {
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j < D; ++j) {
      for (int k = 0; k < 2; ++k) {
        dp[i][j][k] = NOPE;
      }
    }
  }
}

int main() {
  scanf("%s", K);
  scanf("%d", &D);
  N = strlen(K);
  init();
  int ret = dfs(0, 0, false);
  // Exclude zero.
  ret = (1LL * ret + MOD - 1) % MOD;
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 9216
#include<stdio.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
typedef struct{int SPF[1000001];int Primes[1000001];int count[1000001];int sz;}Template;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int MPow(int a,int b){return b?1l*MPow(1l*a*a%MOD,b>>1)*(b&1?a:1)%MOD:1;}
int main(void)
{
  int N=IN(),A=0,factor=1,invsum=0,lcm=1,x=0;
  Template P;*P.SPF=1,*P.Primes=2,*P.count=0,P.sz=1;
  rep(i,500000)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;
  if(!(N&1))P.SPF[N]=2;
  rep(i,499999)
  {
    x=2*(i+1)+1;if(P.SPF[x]==x)P.Primes[P.sz++]=x;
    rep(j,P.sz)
    {
      if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=1000000)P.SPF[x*P.Primes[j]]=P.Primes[j];
      else break;
    }
  }
  rep(i,P.sz/2)P.count[P.Primes[2*i]]=P.count[P.Primes[2*i+1]]=0;
  rep(i,N)
  {
    A=IN();invsum=(invsum+1l*MPow(A,MOD-2))%MOD;
    while(A>1)
    {
      factor=P.SPF[A];
      x=1;A/=factor;
      while(A%factor==0)A/=factor,x++;
      if(P.count[factor]<x)P.count[factor]=x; 
    }
  }
  rep(i,P.sz){if(P.count[P.Primes[i]])lcm=1l*lcm*MPow(P.Primes[i],P.count[P.Primes[i]])%MOD;}
  x=1l*lcm*invsum%MOD;return printf("%d\n",x),0;
}

Measured memory_bytes: 9720
package main

import "fmt"

func main() {
	var a, b int
	for {
		fmt.Scan(&a, &b)
		if a == 0 && b == 0 {
			break
		}
		if a > b {
			fmt.Println(b, a)
		} else {
			fmt.Println(a, b)
		}
	}
}



Measured memory_bytes: 1256